Partilhar via


State Machine Workflows

In the state machine style of workflow authoring, the author models the workflow as a state machine. The workflow itself consists of a set of states. One state is denoted as a start state. Each state can receive a certain set of events. Based on an event, a transition can be made to another state. The state machine workflow can have a final state. When a transition is made to the final state, the workflow is completed.

The following flowchart is an example of a state machine workflow.

State Machine Workflow Example

The following table lists the state machine-related activities in the Windows Workflow Foundation base activity library.

Activity Description

EventDrivenActivity

Used for states that rely on an external event to start executing. The EventDrivenActivity activity must have an activity that implements the IEventActivity interface as its first child activity. For more information, see Using the EventDrivenActivity Activity.

SetStateActivity

Specifies a transition to a new state. For more information, see Using the SetStateActivity Activity.

StateActivity

Represents a state in a state machine; may contain additional State activities. For more information, see Using the StateActivity Activity.

StateInitializationActivity

Executes when a state is entered; may contain other activities. For more information, see Using the StateInitializationActivity Activity.

StateFinalizationActivity

Executes contained activities when leaving a StateActivity activity. For more information, see Using the StateFinalizationActivity Activity.

For more information about workflow authoring styles, see Workflow Authoring Styles.

See Also

Concepts

Sequential Workflows
Workflow Authoring Styles
Using the EventDrivenActivity Activity
Using the SetStateActivity Activity
Using the StateActivity Activity
Using the StateInitializationActivity Activity
Using the StateFinalizationActivity Activity

Other Resources

Developing Workflows