예제 #1
0
        static async Task Main()
        {
            Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            Console.CancelKeyPress += (sender, args) => Environment.Exit(0);

            var processPool  = new ChildProcessPool();
            var randomClient = new RandomClient(processPool);

            while (true)
            {
                var value = await randomClient.NextAsync();

                Console.WriteLine($"[{DateTime.Now}] Next random number is {value}");
                Console.ReadLine();
            }
        }
예제 #2
0
        static async Task Main()
        {
            Console.CancelKeyPress += (sender, args) => Environment.Exit(0);

            var processPool = new ChildProcessPool();

            while (true)
            {
                using (var childProcessLease = processPool.LeaseProcess())
                {
                    var request = new RandomNextRequest()
                    {
                        Id = Guid.NewGuid()
                    };
                    var response = await childProcessLease.ChildProcess.ExecuteAsync <RandomNextResponse>(request).ConfigureAwait(false);

                    Console.WriteLine($"[{DateTime.Now}] Next random number is {response.Value}");
                }

                Console.ReadLine();
            }
        }
예제 #3
0
 public ChildProcessLease(ChildProcessPool pool, ChildProcess childProcess)
 {
     _pool        = pool ?? throw new ArgumentNullException(nameof(pool));
     ChildProcess = childProcess ?? throw new ArgumentNullException(nameof(childProcess));
 }
 public RandomClient(ChildProcessPool processPool)
 {
     _processPool = processPool ?? throw new ArgumentNullException(nameof(processPool));
 }