static void Main(string[] args) { CalculatorClient client1 = new CalculatorClient("WSHttpBinding_ICalculator"); ComplexNum lz1 = new ComplexNum(1.2, 3.4); ComplexNum lz2 = new ComplexNum(1.2, 3.4); Console.WriteLine("\nClient1"); Console.WriteLine("...called addCNum(...)"); ComplexNum result1 = client1.addCNum(lz1, lz2); Console.WriteLine("addCNum(...) = ({0},{1})", result1.realPart, result1.imagPart); Console.WriteLine("Client1 - STOP"); Console.WriteLine("...call of function 1:"); client1.Function1("Client1"); Thread.Sleep(10); Console.WriteLine("...continue after function 1 call"); Console.WriteLine("...call of function 2:"); client1.Function2("Client1"); Thread.Sleep(10); Console.WriteLine("...continue after function 2 call"); Console.WriteLine("...call of function 1:"); client1.Function1("Client1"); Thread.Sleep(10); Console.WriteLine("...continue after function 1 call"); client1.Close(); Console.WriteLine("CLIENT1 - STOP"); Console.WriteLine("\nCLIENT2:"); CallbackHandler myCallbackHandler = new CallbackHandler(); InstanceContext instanceContext = new InstanceContext(myCallbackHandler); CallbackCalculatorClient client2 = new CallbackCalculatorClient(instanceContext); double value1 = 10; Console.WriteLine("...call of Factorial({0})...", value1); client2.Factorial(value1); value1 = 20; Console.WriteLine("...call of Factorial({0})...", value1); client2.Factorial(value1); int value2 = 2; Console.WriteLine("...call of calculation of something..."); client2.CalcSomething(value2); Console.WriteLine("...now I’m waiting for results"); Thread.Sleep(5000); client2.Close(); Console.WriteLine("CLIENT2 - STOP"); }
static void Main(string[] args) { CallbackHandler myCallbackHandler = new CallbackHandler(); InstanceContext instanceContext = new InstanceContext(myCallbackHandler); CallbackBankClient client2 = new CallbackBankClient(instanceContext); Console.WriteLine("...call of Factorial()..."); client2.Balance(); Console.WriteLine("...call of Factorial()..."); client2.Addition(10000); Console.WriteLine("...call of calculation of something..."); client2.Withdraw(10000); Console.WriteLine("...now I’m waiting for results"); client2.Withdraw(20000); Thread.Sleep(5000); client2.Close(); Console.WriteLine("CLIENT2 - STOP"); }