How do you make a WCF Client asynchronous?

我怕爱的太早我们不能终老 提交于 2019-12-11 23:19:33

问题


I have a client that sends a request to a server, and the server answer to him.

I want to do this in an asynchronous way. The client sends a request, the server calculates it and returns it to a service in the client. How can i do this?

p.s. let's say the client wants to do add(int a, int b) and the server needs to send the result to a service that run on the client.


回答1:


A dual binding is only really needed when the server must send information to the client without a request. Since you are making a request, use one of the more basic bindings.

Making the request asynchronous is all about what the client does when it calls the service. One way of doing this is to get the generated client interface to include the event based asynchronous pattern.

When the client calls this method, it simply returns right away. An event is then triggered when the actual response to the request is received. The server itself is completely uninvolved with how the client waits for the response.



来源:https://stackoverflow.com/questions/4639771/how-do-you-make-a-wcf-client-asynchronous

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!