Terminating a Workflow Instance
Should you need to do so, you can easily terminate a workflow instance by executing the Terminate method on the WorkflowInstance object. The string you pass into Terminate is folded into an exception. If you added the WorkflowTerminated handler to your application, you can pull the reason for the termination from the Message property of the exception. You’ll find the exception wrapped in the WorkflowTerminatedEventArgs that are passed into your WorkflowTerminated event handler. This code is already in WorkflowHost, so let’s give it a try. We’ll need to add a single line of code to actually terminate the instance.
Terminating a workflow instance
If the WorkflowHost project’s Program.cs file isn’t still open in Visual ...
Get Microsoft® Windows® Workflow Foundation Step by Step now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.