State machines are not a new citizen of WF but are now here to stay as a solid part of WF. They have a new type of activity, the StateMachine
activity, with two classes to help us define a state machine: state and transition. State helps us define a state that the machine can then be in and a transition helps us define which state changes can occur from a specific state.
In this recipe, we will see how to create a state machine workflow with WF 4.5, execute it, and debug it.
We are going to create a state machine workflow using the following steps:
First open Visual Studio 2012, create a new project by navigating to Visual C# | Workflow, and use the Workflow Console Application template to create a new project. Name it
WFStateMachine
and click on Ok.Close the
Workflow1.xaml
file that will open on creating the project and rename it toMyStateMachine.xaml
. To...