Exemple #1
0
        private void btnSync_Click(object sender, EventArgs e)
        {
            TestProxy.DataServiceClient client = new TestProxy.DataServiceClient();

            string data = client.GetData();

            MessageBox.Show(data);
        }
Exemple #2
0
        private void btnAsync_Click(object sender, EventArgs e)
        {
            TestProxy.DataServiceClient client = new TestProxy.DataServiceClient();
            client.GetDataCompleted += delegate(object src, TestProxy.GetDataCompletedEventArgs args)
            {
                MessageBox.Show(args.Result);
            };

            client.GetDataAsync();
        }
Exemple #3
0
        static void CallService()
        {
            TestProxy.DataServiceClient client = new TestProxy.DataServiceClient();

            try
            {
                Console.WriteLine(client.GetData());
            }
            finally
            {
                // Close the proxy
                client.Close();
            }
        }
Exemple #4
0
        private void btnThread_Click(object sender, EventArgs e)
        {
            Thread th = new Thread(
                delegate()
                {
                    TestProxy.DataServiceClient client = new TestProxy.DataServiceClient();

                    string data = client.GetData();

                    MessageBox.Show(data);
                }
            );

            th.Start();
        }
Exemple #5
0
        static void CallServiceWithExceptionHandling()
        {
            TestProxy.DataServiceClient client = new TestProxy.DataServiceClient();
            try
            {
                // Making calls
                Console.WriteLine(client.GetData());

                // Close the proxy
                client.Close();
            }
            catch (TimeoutException timeEx)
            {
                client.Abort();
            }
            catch (FaultException faultEx)
            {
                client.Abort();
            }
            catch (CommunicationException commProblem)
            {
                client.Abort();
            }
        }