|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
Using the State Machine Workflow Designer
When you are creating a new state machine workflow project in Visual Studio Extensions for Windows Workflow Foundation, you can choose to use a State Machine Workflow Console Application or a State Machine Workflow Library project template. If you choose one of these state machine project templates, the state machine designer is presented as the workflow designer user interface. For information about the state machine project templates, see How to: Create State Machine Workflow Console Applications and How to: Create a State Machine Workflow Library.
A state machine workflow consists of a set of states. One state is denoted as an initial 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 finishes.
State Machine Designer Views
The state machine designer is a freeform designer, which means that the activities can be moved around freely on the design surface. The state machine designer has two views: state view and event-driven view.
The state view shows the state activities and the event-driven activities that can be contained within a state activity. In this view, the transitions from one state to another are represented by lines that extend from the event-driven activity in one state to another state. You can also create transitions by drawing the line yourself. To draw the transition, select the event-driven activity, and then select one of the handles on the activity and drag it. This action draws a line. This line is then attached to the target state, indicating a transition between states.
To access the event driven view, double-click an event-driven activity. The designer that appears is much like the sequential workflow designer. At the top of the designer, a navigation bar shows the hierarchy of the activities up to the event-driven activity that is displayed. You can navigate back to the state view by clicking any element in the displayed hierarchy. If you have drawn a transition from one state to another in the state view, and if you are displaying the event driven view of that activity, a set state activity is added to the event-driven activity for you. If you change the properties of the set state activity, it is reflected back in the state view.
State Machine Workflow Activities
The following table describes the key activities that are used in a state machine workflow designer.
Represents a state in a state machine; may contain additional StateActivity activities. For more information, see Using the StateActivity Activity.
Specifies a transition to a new state. For more information, see Using the SetStateActivity Activity.
Executes when a state is entered; may contain other activities. For more information, see Using the StateInitialization Activity.
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 the first child activity. For more information, see Using the EventDrivenActivity Activity.
The main component in a state machine workflow is the StateActivity activity. As events are captured at various points in a state machine workflow, different states are entered to handle the tasks that are associated with the events. During the workflow lifetime, the workflow may leave and enter several different states. These states connect to each other by using the SetStateActivity activity.
When you drag a new StateActivity onto the workflow design surface, you can add EventDrivenActivity, StateInitializationActivity, StateFinalizationActivity, or additional StateActivity activities as child activities.
|When you use the state machine workflow designer to create workflows, you must monitor the structure of the workflow you are designing with the Document Outline view window. The view of the structure of the state machine workflow in the Document Outline view window mirrors the logical layout of the activities in the workflow markup file. The physical layout of the workflow activities as they appear on the design surface might not mirror the logical layout of the activities in the workflow markup file. To open the Document Outline window, on the View menu, point to Other Windows, and then select Document Outline.|
TasksHow to: Create State Machine Workflow Console Applications
How to: Create a State Machine Workflow Library
Other ResourcesState Machine Workflows
Using the StateActivity Activity
Using the StateInitializationActivity Activity
Using the StateFinalizationActivity Activity
Using the SetStateActivity Activity
Using the EventDrivenActivity Activity
Copyright © 2007 by Microsoft Corporation. All rights reserved.