added SSCLI 1.0
[windows-sources.git] / sdk / samples / WCFSamples / TechnologySamples / Basic / Contract / Service / Asynchronous / CS / client / client.cs
blobac895b1f40ce7c2cf9b0a8223cf4966fd098b451
1 // Copyright (c) Microsoft Corporation. All rights reserved.
3 using System;
5 namespace Microsoft.ServiceModel.Samples
7 // The service contract is defined in generatedClient.cs, generated from the service by the svcutil tool.
9 class Client
11 static void Main()
13 Console.WriteLine("Press <ENTER> to terminate client once the output is displayed.");
14 Console.WriteLine();
16 // Create a client
17 CalculatorClient client = new CalculatorClient();
19 // AddAsync
20 double value1 = 100.00D;
21 double value2 = 15.99D;
22 client.AddCompleted += new EventHandler<AddCompletedEventArgs>(AddCallback);
23 client.AddAsync(value1, value2);
24 Console.WriteLine("Add({0},{1})", value1, value2);
26 // SubtractAsync
27 value1 = 145.00D;
28 value2 = 76.54D;
29 client.SubtractCompleted += new EventHandler<SubtractCompletedEventArgs>(SubtractCallback);
30 client.SubtractAsync(value1, value2);
31 Console.WriteLine("Subtract({0},{1})", value1, value2);
33 // Multiply
34 value1 = 9.00D;
35 value2 = 81.25D;
36 double result = client.Multiply(value1, value2);
37 Console.WriteLine("Multiply({0},{1}) = {2}", value1, value2, result);
39 // Divide
40 value1 = 22.00D;
41 value2 = 7.00D;
42 result = client.Divide(value1, value2);
43 Console.WriteLine("Divide({0},{1}) = {2}", value1, value2, result);
45 Console.ReadLine();
47 //Closing the client gracefully closes the connection and cleans up resources
48 client.Close();
51 // Asynchronous callbacks for displaying results.
52 static void AddCallback(object sender, AddCompletedEventArgs e)
54 Console.WriteLine("Add Result: {0}", e.Result);
57 static void SubtractCallback(object sender, SubtractCompletedEventArgs e)
59 Console.WriteLine("Subtract Result: {0}", e.Result);