示例#1
0
 static void Main(string[] args) {
     using (BasicMathClient proxy = new BasicMathClient()) {
         proxy.Open();
         IAsyncResult result = proxy.BeginAdd(2, 3, ar => {
             Console.WriteLine("result : {0}", proxy.EndAdd(ar));
         }, null);
         while (!result.IsCompleted) {
             Console.WriteLine("Client working...");
             Thread.Sleep(200);
             
         }
         Console.ReadLine();
     }
     
 }
示例#2
0
        static void Main(string[] args)
        {
            using (BasicMathClient client = new BasicMathClient()) {
                client.Open();
                IAsyncResult result = client.BeginAdd(10, 20, (ar) => {
                    Console.WriteLine("Result: {0} ", client.EndAdd(ar));
                }, null);

                while (!result.IsCompleted)
                {
                    Thread.Sleep(1000);
                    Console.WriteLine("Client Working...");
                }
            }
        }
示例#3
0
        static void Main(string[] args)
        {
            //install windows service before use it with developer cmd installutil
            Console.WriteLine("*** The Async Math Client ***");
            using (var proxy = new BasicMathClient())
            {
                proxy.Open();
                IAsyncResult result = proxy.BeginAdd(2, 3, ar => Console.WriteLine("2 + 3 = {0}", proxy.EndAdd(ar)), null);

                while (!result.IsCompleted)
                {
                    Thread.Sleep(200);
                    Console.WriteLine("Client is working...");
                }
            }

            Console.ReadLine();
        }
示例#4
0
 static void Main(string[] args)
 {
     using (BasicMathClient proxy = new BasicMathClient())
     {
         proxy.Open();
         IAsyncResult result = proxy.BeginAdd(2, 3, ar =>
         {
             Console.WriteLine("2 + 3 = {0}",
                               proxy.EndAdd(ar));
         },
                                              null);
         while (!result.IsCompleted)
         {
             Thread.Sleep(200);
             Console.WriteLine("Client working...");
         }
         Console.ReadLine();
     }
 }
示例#5
0
        static void Main()
        {
            Console.WriteLine("***** The Async Math Client *****");

            using (BasicMathClient proxy = new BasicMathClient()) {
                proxy.Open();

                IAsyncResult result = proxy.BeginAdd(2, 3,
                                                     ar => {
                    Console.WriteLine("2 + 3 = {0}", proxy.EndAdd(ar));
                },
                                                     null);

                while (!result.IsCompleted)
                {
                    System.Threading.Thread.Sleep(200);
                    Console.WriteLine("Client working...");
                }
            }
        }
示例#6
0
 private static void Main(string[] args)
 {
     Console.WriteLine("***** The Async Math Client* ****\n");
     using (var proxy = new BasicMathClient())
     {
         proxy.Open();
         // Add numbers in an async manner, using a lambda expression.
         var result = proxy.BeginAdd(2, 3,
                                     ar =>
         {
             Console.WriteLine("2 + 3 = {0}", proxy.EndAdd(ar));
         },
                                     null);
         while (!result.IsCompleted)
         {
             Thread.Sleep(200);
             Console.WriteLine("Client working...");
         }
     }
     Console.ReadLine();
 }
 static void Main(string[] args)
 {
     Console.WriteLine("***** The Async Math Client *****\n");
     using (BasicMathClient proxy = new BasicMathClient())
     {
         proxy.Open();
         //Суммировать числа в асинхронной манере с применением лямбда-выражения
         IAsyncResult result = proxy.BeginAdd(2, 3, ar
                                              =>
         {
             Console.WriteLine("2 + 3 = {0}", arg0: proxy.EndAdd(ar));
         },
                                              null);
         while (!result.IsCompleted)
         {
             Thread.Sleep(200);
             Console.WriteLine("Client working...");
         }
     }
     Console.ReadLine();
 }
示例#8
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** The Async Math Client *****\n");

            using (BasicMathClient proxy = new BasicMathClient())
            {
                proxy.Open();

                // Add numbers in an async manner, using lambda expression
                IAsyncResult result = proxy.BeginAdd(2, 3,
                  ar =>
                  {
                      Console.WriteLine("2 + 3 = {0}", proxy.EndAdd(ar));
                  }, null);

                while (!result.IsCompleted)
                {
                    Thread.Sleep(200);
                    Console.WriteLine("Client working...");
                }
            }
            Console.ReadLine();
        }
示例#9
0
        //you will have to create the MathServiceLibrary because I removed it.
        //use installutil MathWinServiceHost.exe to install
        //in the MathWinService debug directory
        //uninstall using installutil /u MathWinServiceHost.exe
        //in same directory
        private static void Main()
        {
            Console.WriteLine("**** The Async Math Client ****");
            Console.WriteLine("Enter a number..");
            var num1 = int.Parse(Console.ReadLine() ?? throw new InvalidOperationException());

            Console.WriteLine("Enter another number..");
            var num2 = int.Parse(Console.ReadLine() ?? throw new InvalidOperationException());

            using (var proxy = new BasicMathClient())
            {
                proxy.Open();

                //Add numbers in an async manner,using a lambda expression.
                IAsyncResult result = proxy.BeginAdd(num1, num2,
                                                     ar => { Console.WriteLine($"{num1} + {num2} = {proxy.EndAdd(ar)}"); }, null);
                while (!result.IsCompleted)
                {
                    Thread.Sleep(200);
                    Console.WriteLine("Console wroking..");
                }
            }
            Console.ReadLine();
        }