本文整理汇总了C#中ServiceClient.addData方法的典型用法代码示例。如果您正苦于以下问题:C# ServiceClient.addData方法的具体用法?C# ServiceClient.addData怎么用?C# ServiceClient.addData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServiceClient
的用法示例。
在下文中一共展示了ServiceClient.addData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: asyncsyncOperation
public static void asyncsyncOperation()
{
ServiceClient client = new ServiceClient("WSHttpBinding_IService");
Data s1 = new Data() { name = "saeid1" };
Data s2 = new Data() { name = "saeid2" };
client.addData(s1);
client.addData(s2);
//client.getListCompleted += new EventHandler<getListCompletedEventArgs>(client_getListCompleted);
//client.getListAsync();
Console.WriteLine("waiting");
//waits till finishes
client.Close();
//aborts no matter not completed
//client.Abort();
}
示例2: syncOperation
public static void syncOperation()
{
//client.ServiceReference1.ServiceClient client = new client.ServiceReference1.ServiceClient(new BasicHttpBinding(),new EndpointAddress(""));
client.ServiceReference1.ServiceClient client = new ServiceClient("NetTcpBinding_IService");
try
{
Data s1 = new Data() { name="saeid1"};
Data s2 = new Data() { name = "saeid2" };
client.addData(s1);
client.addData(s2);
Data[] result = client.getList();
Console.WriteLine("number of entries: " + result.Length);
client.Close();
}
catch (FaultException fe)
{
Console.WriteLine(fe.GetType());
client.Abort();
}
catch (CommunicationException ce)
{
Console.WriteLine(ce.GetType());
Console.WriteLine(ce.Message);
client.Abort();
}
catch (TimeoutException te)
{
Console.WriteLine(te.GetType());
client.Abort();
}
}