What's the best way to cancel an asynchronous WCF request?

Posted by Pwninstein on Stack Overflow See other posts from Stack Overflow or by Pwninstein
Published on 2010-06-14T17:17:45Z Indexed on 2010/06/14 17:22 UTC
Read the original article Hit count: 249

Filed under:
|
|
|

(Assuming a WCF method called "MyFunction")

Currently, to support canceling a WCF request, I'm using the BeginMyFunction/EndMyFunction methods generated by svcutil (and handling an isCanceled flag when dispatching the results to the main thread). I'd like to use the MyFunctionAsync method (and hooking into MyFunctionAsyncCompleted event instead) for async calls instead of Begin/End.

What is the best/supported way to handle canceling WCF requests if using MyFunctionAsyncCompleted, and still ensuring that the event doesn't get fired on a page that's no longer loaded (i.e. page navigation within a frame).

Thanks!

© Stack Overflow or respective owner

Related posts about wpf

Related posts about wcf