Workflow Lifetime Activities
Activities that affect the lifetime of a workflow are known as workflow lifetime activities, described in the following sections.
InvokeWorkflow Activity
The InvokeWorkflow activity (see Figure 3.12) is used to execute another workflow asynchronously. The InvokeWorkflow activity completes immediately (before the launched workflow starts executing) and the next activity in the branch is executed.
Suspend Activity
The Suspend activity (shown in Figure 3.13) temporarily stops the execution of the current workflow. It can pass an error message back to the host, which can be specified through the Error property in the Suspend activity. The Error property can refer to a string literal, a field or property reference, or an activity reference.
Suspended workflow instances can still receive messages that are queued up until the workflow is restarted. The workflow can only be restarted by the host by calling Resume() on the WorkflowInstance class.
Figure 3.12 An InvokeWorkflow activity.
Figure 3.13 A Suspend activity.
Terminate Activity
A workflow normally completes after all activity branches are finished. If something unexpected occurs in the workflow an exception can be thrown. But an exception can be caught and handled which, depending on the problem, may not be desirable. The Terminate activity (shown in Figure 3.14) guarantees that no other activity will run after this one. As with the suspend activity you can pass an error message back to the host.