Hi
I have a WCF function that is executing long time, so I call the function in UI with backgraundworker... I want to give a feature to cancel the execution, so I abort IComunicationObject, the problem is that Service execution is not stoping, Is there any way to stop Service execution in this case?
views:
862answers:
2
+1
A:
Make a CancelOperation() method which sets some static ManualResetEvent in your service. Check this event in your Operation method frequently. Or it can be CancelOperation(Guid operationId) if your service can process multiple operation calls concurrently.
Dmitry Ornatsky
2009-06-04 10:20:29
Thanks for response! Is this a good practice? or just a way to do that?
ArsenMkrt
2009-06-04 10:35:27
Just a way to do that, not sure if there are any 'best prcactices'
Dmitry Ornatsky
2009-06-04 11:15:15
+2
A:
You may not need a BackgroundWorker. You can either make the operation IsOneWay, or implement the asynchronous pattern. To prevent threading issues, consider using the SynchronizationContext. Programming WCF Services does a great job at explaining these.
Mark Good
2009-06-04 11:58:10