J'utilise .NET 3.5This est une question connexe mais en utilisant TPL Async Library, depuis que je suis en 3.5 j'ai besoin d'une autre approche.L'appel async WCF sans référence de service en utilisant ChannelFactory
Je l'habitude d'appeler un WCF de manière asynchrone en ajoutant une référence de service et la création de ses opérations async en utilisant Visual Studio 2010.
Maintenant, j'ai créé un proxy dynamique utilisant la CreateChannel<T>
de la classe ChannelFactory
et je dois appeler une méthode de manière asynchrone. Voici comment je crée le proxy 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();
}
Je n'ai pas besoin de la réponse du service.
se réfèrent à http://stackoverflow.com/ question ns/400798/how-to-make-a-call-to-my-wcf-service-asynchrone – vibhu