[英]Asynchronous WCF service call
I'm calling WCF service asynchronously from the WP page using EAP: 我正在使用EAP从WP页面异步调用WCF服务:
ServiceReference1.Service1Client proxy = new ServiceReference1.Service1Client();
proxy.loginCompleted += DoLogin;
proxy.loginAsync("user", "password");
And in the Rererence.cs I see the following code that looks like APM: 在Rererence.cs中,我看到以下代码看起来像APM:
public System.IAsyncResult Beginlogin(string usn, string pwd, System.AsyncCallback callback, object asyncState)
{
object[] _args = new object[2];
_args[0] = usn;
_args[1] = pwd;
System.IAsyncResult _result = base.BeginInvoke("login", _args, callback, asyncState);
return _result;
}
public bool Endlogin(System.IAsyncResult result)
{
object[] _args = new object[0];
bool _result = ((bool)(base.EndInvoke("login", _args, result)));
return _result;
}
Why do I have APM methods when I'm calling WCF service using EAP? 当我使用EAP调用WCF服务时,为什么要使用APM方法?
When you generate a Service Reference and set it to generate asynchronous operations on the client side, from .NET 3.5 and above, it will call svcutil.exe
with the /async /tcv:Version35
parameters and will generate both APM and EAP asynchronous operations. 当您生成服务引用并将其设置为在客户端生成异步操作时,从.NET 3.5及更高版本开始,它将使用
/async /tcv:Version35
参数调用svcutil.exe
,并将生成APM和EAP异步操作。
When using /tcv:Version35 with the /async switch, both event-based and callback/delegate-based asynchronous methods are generated.
将/ tcv:Version35与/ async开关一起使用时,将生成基于事件和基于回调/委托的异步方法。 In addition, support for LINQ-enabled DataSets and DateTimeOffset is enabled.
此外,还启用了对启用LINQ的DataSet和DateTimeOffset的支持。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.