Fault Handling and Cancellation

Fault Handling

What happens if an activity throws an exception? You cannot place a try/catch handler around it as you can in code. The Fault Handling example illustrates how to handle exceptions thrown in the course of an executing activity. We have a simple workflow of three code activities. Initially, the middle activity whose ExecuteCode delegate throws an exception is disabled (see Figure 31).

FIGURE 31 Fault Handling Example Workflow

image

Running the example causes the Start and Finish activities, as well as the WorkflowCompleted event handler to write messages to the console. The file exception.cs defines two ...

Get Building Applications with Windows Workflow Foundation (WF): Advanced Workflow Features 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.