State Machine Terminology

State Machine Terminology

This section defines the state machine vocabulary used throughout this topic.

Action
A description of an activity that is to be executed at a given moment.

 

State
A situation in which a state machine can execute some actions and/or waiting for some events to occur.

 

Entry Action
An action executed when entering the state

 

Exit Action
An action executed when exiting the state

 

Transition
A directed relationship between two states which represents the complete response of a state machine to an occurrence of an event of a particular type.

 

Trigger
An event which may fire the transition.

 

Condition
A constraint which will fire the transition only when it is evaluated to  true after the trigger occurs.

 

Transition Action
An action which is executed when performing a certain transition.

 

Conditional Transition
A transition with an explicit condition.

 

Self-transition
A transition which transits from a state to itself.

 

Initial State
A state which represents the starting point of the state machine.

 

Final State
A state which represents the completion of the state machine.

 

State Machine Concepts

State machine workflow provide a modeling style with which you can model your workflow in an event-driven manner. A state machine consists of a set of states. Each state can have a set of transitions which specify the execution logic between the states. There are several classes in the state machine runtime:

StateMachine itself is an activity, which means it can be used any place in a workflow that an activity can be used. A state machine can have multiple states. It must have an initial state but can have zero or multiple final states. You can define variables in the scope of a state machine.

State is not an activity and it can only be used inside a state machine. A state can have an entry/exit action which will be executed every time the workflow enters or exits the state. You can specify any activity as the entry/exit action, including another StateMachine activity. A state can have a set of transitions which specifies the possible destination states when some trigger occurs.

Ee264171.note(en-us,VS.100).gifNote:
While a StateMachine activity can be used any place an activity can be used, including inside a State, a State cannot directly contain another State.

Initial/Final state represents the start/completion of the entire state machine accordingly. A state cannot be initial state and final state at the same time. Final state cannot have any entry/exit action or transitions.

Transition is not an activity and it can only be used inside a state machine. A transition must have a state set as its target. It must have a trigger which is used to start the transition as well. You can specify any activity as the trigger. You can also specify an expression as the condition of a transition. In this case, the transition will be performed only when the trigger is completed and the condition is evaluated to be true. If not, the transition won’t be performed and the trigger will be rescheduled. A transition can contain a transition action which will be executed when the transition is occurs.

You can have multiple transitions share the same trigger. In this case, all the transitions must have conditions specified. The target state of a transition is not necessarily a different state, which means a state can have self-transition pointing to itself. In this case, the entry/exit action will be executed as usual.

For more information and sample code, see How to: Create a State Machine Workflow and Windows Workflow Foundation (WF4) - Introduction to State Machine Hands On Lab.

See Also

你可能感兴趣的:(mac)