public Main(string[] args) { InitializeComponent(); IPEndPoint ep = null; if (args.Length > 0) { string[] split = args[0].Split(':'); if (split.Length == 2) { IPAddress ip; int port; if (!IPAddress.TryParse(split[0], out ip)) { IPAddress[] addr = Dns.GetHostAddresses(split[0]); if (addr.Length == 0) Console.WriteLine("Invalid IP address"); else ip = addr[0]; } if (ip != null) { if (!int.TryParse(split[1], out port)) Console.WriteLine("Invalid port"); else ep = new IPEndPoint(ip, port); } } else { Console.WriteLine("Invalid arguments"); } } RenderHost host; if (ep != null) { host = new RenderHost(ep, 8); } else { host = new RenderHost(new IPEndPoint(Dns.GetHostAddresses("samplehost.net")[0], 443), 8); // Address of external render host, and number of tasks this host can perform simultaneously } calc = new ExternalMandelbrotCalculator(); calc.HostSelector = new HostSelector(); calc.HostSelector.AddHost(host); colorizers = new List<Colorizer>(); colorizers.Add(new MandelbrotColorizer()); }
public void AddHost(RenderHost host) { lock (threadlock) renderHosts.Add(host, host.NumWorkers); resevent.Set(); }