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(); } }
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..."); } } }
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(); }
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(); } }
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..."); } } }
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(); }
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(); }
//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(); }