If the workflow is very rigid then you go for sequential workflow and if the workflow is dynamic then go for State machine workflow. For instance you have placed an order and the order will not pass until your supervisor approves is a rigid flow. Because your order has to be approved by a supervisor or else it will not be approved. But if your order moves from one place to other place. For instance it moves from approval to waiting and then clarification a state machine work flow model is more appropriate.
Below is a simple code snippet which shows practically how to use sequential work flow. Let try to understand step by step as marked in the figure:- 1 – First you need to select System.workflow namespace. 2, 3 and 4 – In these three steps we created code object and linked them with activity. 5, 6, 7 and 8 – We start the workflow and create workflow instance object to run the sequential workflow. You can see the output in 8. Depending on how you add the activity in section 3 it executes sequentially. Because we have added codeactivity1 first it executes the first activity first. The sequence on how you add the activity to the activities collection the activities are run.