Beispiel #1
0
        private static void Main(string[] args)
        {
            //SYNC PART

            /*
             * var syncClient = new ComplexCalculatorClient();
             *
             * int[] inputArray = { 24, 43, 22, 33, 11, 3, 4, 53, 221 };
             *
             * Console.WriteLine("Input: {24, 43, 22, 33, 11, 3, 4, 53, 221}");
             *
             * var spec = new ServiceReference1.RandomSpecification { IntNumbersArray = inputArray };
             *
             * var result = syncClient.Random(spec);
             * Console.WriteLine("Sync Result: " + result.Result);
             * Console.WriteLine("Sync Time: " + result.Time);
             * Console.WriteLine("SPAM");
             * Console.WriteLine("SPAM");
             * Console.WriteLine("SPAM");
             * Console.WriteLine("SPAM");
             * Console.WriteLine("SPAM");
             * Console.WriteLine("SPAM");
             * Console.WriteLine("SPAM");
             */

            //ASYNC CALLBACK
            int[] inputArray     = { 24, 43, 22, 33, 11, 3, 4, 53, 221 };
            var   handler        = new CallbackHandler();
            var   context        = new InstanceContext(handler);
            var   callbackClient = new CallbackCalculatorClient(context);

            /*
             * DateTime date = new DateTime(2018, 2, 28);
             * Console.WriteLine("First date: " + date);
             * callbackClient.DateDiffAsync(date);
             * Console.WriteLine("test");
             * Console.WriteLine("test");
             * Console.WriteLine("test");
             * Console.WriteLine("test");
             * Console.WriteLine("test");
             * Console.Read();
             *
             */
            Console.WriteLine("Input: {24, 43, 22, 33, 11, 3, 4, 53, 221}");

            var specification = new ServiceReference2.RandomSpecification {
                IntNumbersArray = inputArray
            };

            callbackClient.AsyncRandom(specification);
            Console.WriteLine("SPAM");
            Console.WriteLine("SPAM");
            Console.WriteLine("SPAM");
            Console.WriteLine("SPAM");
            Console.WriteLine("SPAM");
            Console.WriteLine("SPAM");
            Console.WriteLine("SPAM");
            Console.Read();
        }
Beispiel #2
0
        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");
        }