Friday, September 21, 2012

concurrent call in WCF while time consuming service call invoked

concurrent call in WCF while time consuming service call invoked

Am doing some time consuming File operation in WCF web service, so until this call completed i cant make any other service calls from my application.

So i planned use the TPL

  Task.Factory.StartNew(() =>             {                                     CheckFileandCopy(path,fileName);             }); 

it works, and return true, but the problem is, the completed event doesnt have the actual result, coz the process is running in seperate thread, so am not getting the actual complete event, how i can return the complete event once the task is done, and also how i can make concurrent call when the time consuming method is invoked

Answers & Comments...

Answer: 1

You have basically two options:

  • Do asynchronous calls client side. If you generate a proxy including async methods (for example see this msdn page this would be easy.
  • Make things asynchronous, server side. This is similar what you did in your example. Only thing missing is the callback with the actual result. For this you can use the duplex scenario where the client is able to receive a call from the service just as if the client is also a service. Note that not all scenario's/bindings support this.

In both cases reading through this msdn article on sessions and concurrency may help with understanding things.

by : Jeroenhttp://stackoverflow.com/users/419956




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog