Suspend and Terminate Sample

Download sample

This sample demonstrates the use of two basic activities: SuspendActivity and TerminateActivity.

The SuspendActivity activity causes a workflow to be suspended. It also causes the workflow runtime's WorkflowSuspended event to be raised, at which point the workflow instance can be resumed. The TerminateActivity activity ends the workflow and causes the workflow's WorkflowTerminated event to be raised.

The first activity in the workflow is a SuspendActivity activity. This is followed by a CodeActivity activity, and it ends with a TerminateActivity activity. When the workflow encounters the SuspendActivity activity, the workflow is suspended and the workflow runtime's WorkflowSuspended event occurs. In the WorkflowSuspended event handler, the host resumes the workflow instance by using the WorkflowInstance.Resume method.

The console output from the sample appears as follows:

Output from Suspend and Terminate sample

To build the sample

  1. Download the sample by clicking Download Sample in this topic.

    This extracts the sample project to your local hard disk.

  2. Click Start, point to Programs, point to Microsoft Windows SDK, and then click CMD Shell.

  3. Go to the source directory of the sample.

  4. At the command prompt, type MSBUILD <Solution file name>.

To run the sample

  1. In the SDK Command Prompt window, run the .exe file in the SuspendAndTerminate\bin\debug folder (or the SuspendAndTerminate\bin folder for the Visual Basic version of the sample), which is located below the main folder for the sample.

See Also



Other Resources

Using the Suspend Activity
Using the Terminate Activity
Activities Samples
Windows Workflow Foundation Samples

© 2007 Microsoft Corporation. All rights reserved.