private void btnSync_Click(object sender, EventArgs e) { TestProxy.DataServiceClient client = new TestProxy.DataServiceClient(); string data = client.GetData(); MessageBox.Show(data); }
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(); }
static void CallService() { TestProxy.DataServiceClient client = new TestProxy.DataServiceClient(); try { Console.WriteLine(client.GetData()); } finally { // Close the proxy client.Close(); } }
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(); }
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(); } }