views:

99

answers:

1

Hi! I've been trying to figure out how to use System.Threading.Tasks to asynchronously invoke a synchronous WCF method while supporting cancellation, error handling, result-return and multiple continuations.

I've come across a number of incomplete demos but they all seem to fall a bit short. As an example I can't use cooperative cancellation since all of my WCF methods are atomic and relatively long lived.

Anyway, I'd appreciate any help in this regard....

A: 

I would consider an alternate option - generate the WCF client interface with asynchronous methods. This will allow you to make all WCF service calls asynchronously (from the perspective of the client application), which will allow you to support cancellation, error-handling, result-return, etc.

The benefit is that you won't be blocking a thread on the worker thread pool (like System.Threading.Tasks will), and you don't have the worry of trying to figure out how to cancel a synchronous WCF call in your worker thread.

Is there a reason that you must make a synchronous WCF call?

Sam
Thanks for your quick reply. Unfortunately, I use a custom proxy so I can't use the native WCF async...
lsb