예제 #1
0
파일: client.cs 프로젝트: ssickles/archive
        static void Main()
        {
            // Construct InstanceContext to handle messages on callback interface
            InstanceContext instanceContext = new InstanceContext(new CallbackHandler());

            // Create a client with given client endpoint configuration
            CalculatorDuplexClient client = new CalculatorDuplexClient(instanceContext);

            Console.WriteLine("Press <ENTER> to terminate client once the output is displayed.");
            Console.WriteLine();

            // Call the AddTo service operation.
            double value = 100.00D;
            client.AddTo(value);

            // Call the SubtractFrom service operation.
            value = 50.00D;
            client.SubtractFrom(value);

            // Call the MultiplyBy service operation.
            value = 17.65D;
            client.MultiplyBy(value);

            // Call the DivideBy service operation.
            value = 2.00D;
            client.DivideBy(value);

            // Complete equation
            client.Clear();

            Console.ReadLine();

            //Closing the client gracefully closes the connection and cleans up resources
            client.Close();
        }
예제 #2
0
        static void Main(string[] args)
        {
            // Picks up configuration from the config file.

            CalculatorDuplexClient wcfClient
                = new CalculatorDuplexClient(new InstanceContext(new CallbackHandler()));

            try
            {
                // Call the AddTo service operation.
                double value = 100.00D;
                wcfClient.AddTo(value);

                // Call the SubtractFrom service operation.
                value = 50.00D;
                wcfClient.SubtractFrom(value);

                // Call the MultiplyBy service operation.
                value = 17.65D;
                wcfClient.MultiplyBy(value);

                // Call the DivideBy service operation.
                value = 2.00D;
                wcfClient.DivideBy(value);

                // Complete equation.
                wcfClient.Clear();

                // Wait for callback messages to complete before
                // closing.
                System.Threading.Thread.Sleep(5000);

                // Close the WCF client.
                wcfClient.Close();
                Console.WriteLine("Done!");
                Console.ReadLine();
            }
            catch (TimeoutException timeProblem)
            {
                Console.WriteLine("The service operation timed out. " + timeProblem.Message);
                wcfClient.Abort();
                Console.Read();
            }
            catch (CommunicationException commProblem)
            {
                Console.WriteLine("There was a communication problem. " + commProblem.Message);
                wcfClient.Abort();
                Console.Read();
            }
        }
예제 #3
0
        static void Main(string[] args)
        {
            // Picks up configuration from the config file.

            CalculatorDuplexClient wcfClient
              = new CalculatorDuplexClient(new InstanceContext(new CallbackHandler()));
            try
            {
                // Call the AddTo service operation.
                double value = 100.00D;
                wcfClient.AddTo(value);

                // Call the SubtractFrom service operation.
                value = 50.00D;
                wcfClient.SubtractFrom(value);

                // Call the MultiplyBy service operation.
                value = 17.65D;
                wcfClient.MultiplyBy(value);

                // Call the DivideBy service operation.
                value = 2.00D;
                wcfClient.DivideBy(value);

                // Complete equation.
                wcfClient.Clear();

                // Wait for callback messages to complete before
                // closing.
                System.Threading.Thread.Sleep(5000);

                // Close the WCF client.
                wcfClient.Close();
                Console.WriteLine("Done!");
                Console.ReadLine();
            }
            catch (TimeoutException timeProblem)
            {
                Console.WriteLine("The service operation timed out. " + timeProblem.Message);
                wcfClient.Abort();
                Console.Read();
            }
            catch (CommunicationException commProblem)
            {
                Console.WriteLine("There was a communication problem. " + commProblem.Message);
                wcfClient.Abort();
                Console.Read();
            }
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Starting program.");
            // Construct InstanceContext to handle messages on callback interface
            InstanceContext instanceContext = new InstanceContext(new CallbackHandler());
            // Create a client
            Console.WriteLine("Creating client.");
            CalculatorDuplexClient client = new CalculatorDuplexClient(instanceContext);
            //perform operations
            Console.WriteLine("Adding 10");
            client.AddTo(10);
            Console.WriteLine("Substracting 2");
            client.SubtractFrom(2);
            Console.WriteLine("Multiplying by 100");
            client.MultiplyBy(100);
            Console.WriteLine("Dividing by 6");
            client.DivideBy(6);
            Console.WriteLine("Adding -89");
            client.AddTo(-89);

            Console.ReadLine();
        }
예제 #5
0
        static void Main(string[] args)
        {
            // Construct InstanceContext to handle messages on callback interface.
            InstanceContext instanceContext = new InstanceContext(new CallbackHandler());

            // Create a client.
            CalculatorDuplexClient client = new CalculatorDuplexClient(instanceContext);

            Console.WriteLine("Press <ENTER> to terminate client once the output is displayed.");
            Console.WriteLine();

            // Call the AddTo service operation.
            double value = 100.00D;

            client.AddTo(value);

            // Call the SubtractFrom service operation.
            value = 50.00D;
            client.SubtractFrom(value);

            // Call the MultiplyBy service operation.
            value = 17.65D;
            client.MultiplyBy(value);

            // Call the DivideBy service operation.
            value = 2.00D;
            client.DivideBy(value);

            // Complete equation.
            client.Clear();

            Console.ReadLine();

            //Closing the client gracefully closes the connection and cleans up resources.
            client.Close();
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Starting program.");
            // Construct InstanceContext to handle messages on callback interface
            InstanceContext instanceContext = new InstanceContext(new CallbackHandler());

            // Create a client
            Console.WriteLine("Creating client.");
            CalculatorDuplexClient client = new CalculatorDuplexClient(instanceContext);

            //perform operations
            Console.WriteLine("Adding 10");
            client.AddTo(10);
            Console.WriteLine("Substracting 2");
            client.SubtractFrom(2);
            Console.WriteLine("Multiplying by 100");
            client.MultiplyBy(100);
            Console.WriteLine("Dividing by 6");
            client.DivideBy(6);
            Console.WriteLine("Adding -89");
            client.AddTo(-89);

            Console.ReadLine();
        }