static void Main(string[] args) { ChannelServices.RegisterChannel(new TcpChannel(), false); GridJobController controller = (GridJobController)Activator.GetObject(typeof(GridJobController), "tcp://localhost:3000/Grid"); if (controller == null) { Console.WriteLine("could not locate server"); return; } JobExecutor exe = new JobExecutor(); for (int i = 0; i < 100; i++) { var job = controller.GetJob(); if (job == null) { break; } Console.WriteLine($"Берем работу: " + i); //System.Threading.Thread.Sleep(500); controller.SetResult(job, exe.Execute(job)); } Console.WriteLine("END"); Console.ReadKey(); }
static void Main(string[] args) { ChannelServices.RegisterChannel(new TcpChannel(), false); GridJobController controller = (GridJobController)Activator.GetObject(typeof(GridJobController), "tcp://localhost:3000/Grid"); if (controller == null) { Console.WriteLine("could not locate server"); return; } bool q = false; while (!q) { try { JobExecutor exe = new JobExecutor(); var start = DateTime.Now; var hasJobs = false; for (int i = 0; i < 100; i++) { var job = controller.GetJob(); if (job == null) { break; } hasJobs = true; //Console.WriteLine($"Берем работу: " + i); var res = exe.Execute(job); controller.SetResult(res); } var end = DateTime.Now; if (hasJobs) { Console.WriteLine((end - start).TotalMilliseconds + " ms."); } System.Threading.Thread.Sleep(500); } catch (Exception ex) { Console.WriteLine(ex); } if (Console.KeyAvailable && Console.ReadKey().Key == ConsoleKey.Q) { break; } } }