The Problem SolverWIndows Workflow Foundation
HomeShow ChangesEditPrintRecent ChangesSubscriptionsLost and FoundFind ReferencesRename



19-10-2006 11:46:25

List all versions

State Machine Workflow Activity

The StateMachineWorkflowActivity is an activity container used to create workflows that follow a state machine model.

The StateMachineWorkflowActivity is a CompositeActivity, meaning the StateMachineWorkflowActivity can contain other activities. The StateMachineWorkflowActivity and the EventDrivenActivity activities are the only permitted child activities of the StateMachineWorkflowActivity. EventDrivenActivity activities are permitted because the root activity itself behaves like a state. Therefore, you can have EventDrivenActivity activities at the root level that are used by all the State activities in the StateMachineWorkflowActivity. EventDrivenActivity activities at this level provide a global mechanism for processing workflow events and automate state transitions. StateActivity activities provide a mechanism to define the various stages in the model.

The StateMachineWorkflowActivity has properties that are required for the execution of the state machine workflow. Most notably, the StateMachineWorkflowActivity has two properties that are important: InitialState and CompletedState.

The InitialState of the state machine, as the name suggests, is the state in which the state machine will be when an instance of the state machine is created. The InitialState property is mandatory and must be provided when a StateMachineWorkflowActivity is created. The InitialState of the state machine is like any other state activity that is contained within the state machine. The state activity can be a direct child of the StateMachineWorkflowActivity root activity and a StateMachineWorkflowActivity can have only one InitialState.

The CompletedState of the StateMachineWorkflowActivity is a StateActivity activity that is designated as the end state of the StateMachineWorkflowActivity. When a transition is made to the CompletedState, the workflow execution is completed. The CompletedState is not mandatory. This means that you can have a StateMachineWorkflowActivity that is not completed. This does not mean that the state machine workflow is always active in memory. The StateMachineWorkflowActivity might be unloaded as it waits for an event.

StateMachineWorkflowActivity activities that never complete are especially useful in processing long running business transactions. Consider a purchase order received by a supplier. The fact that the purchase order was fulfilled does not mean that the purchase order process is over. The goods that are part of the purchase order might be returned or the purchase order might be amended and have additional items added to it after the fulfillment. Sometimes there might be a requirement to keep the purchase order records for an extended period of time for legal or other purposes. The fact that a workflow does not finish just means that the workflow remains in an unloaded state. There may be a case for retiring the workflows, which means that after a set period of time the workflow instance may be forced to shut down.

Wiki Usage

This wiki site is supposed to be a shared resource. As a shared resource everyone is encouraged to add new content or modify existing content!

Enjoy the WF wiki.

Recent Topics