本文整理汇总了C#中CalculatorClient.Open方法的典型用法代码示例。如果您正苦于以下问题:C# CalculatorClient.Open方法的具体用法?C# CalculatorClient.Open怎么用?C# CalculatorClient.Open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CalculatorClient
的用法示例。
在下文中一共展示了CalculatorClient.Open方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
CalculatorClient client1 = new CalculatorClient("calculatorservice");
client1.Open();
CalculatorClient client2 = new CalculatorClient("calculatorservice");
client2.Open();
client1.Close();
client2.Close();
Console.WriteLine("ChannelFactory的状态: {0}", client1.ChannelFactory.State);
Console.WriteLine("ChannelFactory的状态: {0}\n", client2.ChannelFactory.State);
EndpointAddress address = new EndpointAddress("http://127.0.0.1:3721/calculatorservice");
Binding binding = new WS2007HttpBinding();
CalculatorClient client3 = new CalculatorClient(binding, address);
client3.Open();
CalculatorClient client4 = new CalculatorClient(binding, address);
client4.Open();
client3.Close();
client4.Close();
Console.WriteLine("ChannelFactory的状态: {0}", client3.ChannelFactory.State);
Console.WriteLine("ChannelFactory的状态: {0}", client4.ChannelFactory.State);
Console.Read();
}
示例2: Main
static void Main(string[] args)
{
Console.WriteLine("Client Connecting...");
CalculatorClient client = new CalculatorClient();
client.Open();
Console.Write("Adding 2 + 2 - Answer: ");
Console.WriteLine(client.Add(2, 2));
Console.Write("Subtracting 2 - 2 - Answer: ");
Console.WriteLine(client.Subtract(2, 2));
Console.Write("Dividing 2 / 2 - Answer: ");
Console.WriteLine(client.Divide(2, 2));
Console.Write("Multiplying 2 * 2 - Answer: ");
Console.WriteLine(client.Multiply(2, 2));
client.Close();
Console.ReadLine();
}