Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
372 views
in Technique[技术] by (71.8m points)

c# - How do you make a WCF Client asynchronous?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...