views:

178

answers:

1

I have implemented a queuing mechanism including UI for running specific types of workflows (WF 3.5), where I wanted to include a possibility for a user to cancel / terminate the workflow. The termination doesn't have to be synchronous, it would be enough to show that the cancellation is in progress and let him refresh the state later.

So far I have managed to simply use the workflow instance's function Terminate() to kill the workflow, which works perfectly and even synchronously, but it seems that it is not giving the workflow any chance to react to the termination. What I have tried was :

  1. Create a Cancellation handler at the level of the workflow, this was not executed.
  2. Create a Fault handler at the level of the workflow, with the fault type of WorkflowTerminatedException. This wasn't executed either.

Basically it seems that termination means really to immediately kill the workflow no matter what it is currently doing. Is there a way to :

  • Handle the termination (with the Terminate() function) in any other way ? (maybe some settings which I've missed)
  • Cancel the workflow externally in such a way that its cancellation handler or fault handler are executed giving it the chance to tidy up etc. ?
+2  A: 

Strangely enough, I was thinking about this earlier today.

Maybe you find this link useful: Stopping a build > Cancelling a workflow as its talks about a possible approach.

Rubens Farias
Thanks ! It's a little bit trickier than I expected but the article seems quite helpful ;)
Thomas Wanner