コード例 #1
0
        private static void GreetTogether()
        {
            var threads = new Thread[ThreadCount];
            var clients = new IHelloService[ThreadCount];

            for (int i = 0; i < ThreadCount; i++)
            {
                clients[i] = CreateClient();
                var state = new HelloServiceInvoker(i, clients[i]);
                threads[i] = new Thread(new ThreadStart(state.InvokeService));
            }

            foreach (Thread t in threads)
            {
                t.Start();
            }

            foreach (Thread t in threads)
            {
                t.Join();
            }

            foreach (IHelloService t in clients)
            {
                ((IChannel)t).Close();
            }
        }
コード例 #2
0
        private static void GreetOnce()
        {
            Console.WriteLine("First message invocation: ");
            IHelloService client = CreateClient();

            ((IChannel)client).Open();
            var invoker = new HelloServiceInvoker(0, client);

            invoker.InvokeService();
        }
コード例 #3
0
        private static void GreetTogether()
        {
            var threads = new Thread[ThreadCount];
            var clients = new IHelloService[ThreadCount];
            for (int i = 0; i < ThreadCount; i++)
            {
                clients[i] = CreateClient();
                var state = new HelloServiceInvoker(i, clients[i]);
                threads[i] = new Thread(new ThreadStart(state.InvokeService));
            }

            foreach (Thread t in threads)
            {
                t.Start();
            }

            foreach (Thread t in threads)
            {
                t.Join();
            }

            foreach (IHelloService t in clients)
            {
                ((IChannel)t).Close();
            }
        }
コード例 #4
0
 private static void GreetOnce()
 {
     Console.WriteLine("First message invocation: ");
     IHelloService client = CreateClient();
     ((IChannel)client).Open();
     var invoker = new HelloServiceInvoker(0, client);
     invoker.InvokeService();
 }