views:

40

answers:

1

i am learning it, but don't know the best scenarios for use them(both state machine workflow and sequential workflow.

+1  A: 

Take a look into this explanation: State Machines In Windows Workflow

A sequential workflow is a predictable workflow. The execution path might branch, or loop, or wait for an outside event to occur, but in the end, the sequential workflow will use the activities, conditions, and rules we've provided to march inevitably forward. The workflow is in control of the process.

A state-machine workflow is an event driven workflow. That is, the state machine workflow relies on external events to drive the workflow to completion. We define the legal states of the workflow, and the legal transitions between those states. The workflow is always in one of the states, and has to wait for an event to arrive before transitioning to a new state. Generally, the important decisions happen outside of the workflow. The state machine defines a structure to follow, but control belongs to the outside world.

This article also offers a good (but very similar) explanation: State Machine Workflows in Windows Workflow Foundation:

In sequential workflows all decisions to progress in the workflow are taken by the workflow itself. There’s a well defined start and well defined end. Between there’s a flow consisting of branches and loops to direct the flow. This means the workflow is in control.

With state machine workflows there’s no real predefined path of all steps to undertake for a certain solution. State machines take another approach. They wait for events to happen and based on these events they change their state. State machines are used when the decisions are coming in from an external application and are unpredictable. So especially when there’s user interaction needed a state machine is a more convenient solution.

Rubens Farias