我使用的是.NET 3.5This是一個相關的問題,但使用TPL異步庫,因爲我在3.5我需要另一種方法。使用ChannelFactory調用不帶服務引用的異步WCF
我曾經通過添加服務引用和創建它的異步操作使用Visual Studio 2010
現在我已經創建使用的ChannelFactory
類的CreateChannel<T>
動態代理異步調用WCF,我需要調用異步方式。這是我如何創建WCF代理:
public MyInterface Proxy { get; set; }
BasicHttpBinding binding = new BasicHttpBinding();
EndpointAddress ep = new EndpointAddress("http://localhost/myEndpoint");
Proxy = ChannelFactory<MyInterface>.CreateChannel(binding, ep);
// I call my method
Proxy.MyMethod();
[ServiceContract]
public Interface MyInterface
{
[OperationContract]
void MyMethod();
}
我不需要服務響應。
指http://stackoverflow.com/ questio ns/400798/how-to-make-a-call-to-my-wcf-service-asynchronous – vibhu