开发者

WCF - AsyncPattern=true or IsOneWay=true

Few methods in my WCF service are quite time taking - Generating Reports and Sending E-mails.

According to current requirement, it is required so that Client application just submits the request and then do not wait for the whole process to complete. It will allow开发者_如何学JAVA user to continue doing other operations in client applications instead of waiting for the whole process to finish.

I am in a doubt over which way to go:

AsyncPattern = true OR  
IsOneWay=true 

Please guide.


It can be both.

Generally I see no reason for WCF operation to not be asynchronous, other than developer being lazy.


You should not compare them, because they are not comparable.

In short, AsyncPattern=True performs asynchronous invocation, regardless of whether you're returning a value or not.

OneWay works only with void methods, and puts a lock on your thread waiting for the receiver to ack it received the message.


I know this is an old post, but IMO in your scenario you should be using IsOneWay on the basis that you don't care what the server result is. Depending on whether you need to eventually notify the client (e.g. of completion or failure of the server job) then you might also need to look at changing the interface to use SessionMode=required and then using a Duplex binding.

Even if you did want to use asynchronous 2-way communication because your client DID care about the result, there are different concepts:

  • AsyncPattern=true on the Server - you would do this in order to free up server resources, e.g. if the underlying resource (?SSRS for reporting, Mail API etc) supported asynchronous operations. But this would benefit the server, not the client.
  • On the client, you can always generate your service reference proxy with "Generate Asynchronous Operations" ticked - in which case your client won't block and the callback will be used when the operation is complete.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜