Introduction To Windows WorkFlow Foundation(WWF)
Posted by Pranav Dave on March 10, 2010
INTODUCTION
In this article I will give some brief introduction to Windows Workflow Foundation (WF) using small example. Windows Workflow Foundation (WF) is a Microsoft technology for defining, executing, and managing workflows. This technology was first released in November 2006 as a part of .NET Framework 3.0. The Windows Workflow foundation provides a platform built on the .Net Framework for building workflows. It is not an application or a server product, and is included as a component of the .Net 3.0 framework. It is kind of flowchart that represents various steps to be executed in your application.
There are 2 major features of WWF:-
- Visual Representation of process (es)
- Can be dynamically modified at run-time
There are two major types of workflows:-
- Sequential workflows: used for well-defined, process workflows
- State Machine workflows: Organized as state machine diagrams, typically used for workflows with human interaction.
EXAMPLE
Here I will represent a small startup example from the Microsoft press book. This example will validate the postal code based on the condition. Here I will represent example in the series of steps to create a simple workflow console example.
STEP 1:-
Create a Workflow console application. Open visual studio 2008. Select File -> New -> Project from the menu. New project dialog box opens. Select Sequential Workflow console application from the available templates. Specify the project name in the name textbox and click on the ok button to create console application as shown below. We will first start with the designing part.

STEP 2:-
It will create the application with the default files as shown below.
The application will look something as shown below.
STEP 3:-
Drag and drop the IfElse activity from the toolbox as shown below.
It will create the IfElseActivity with two activity branch as shown below.
STEP 4:-
Specify the condition for the IfElseBranchActivity1 as shown below. Select IfElseBranchActivity1 and click on the properties tab. Select Code condition from the condition dropdown menu.
Give the condition name as EvaluatePostalCode in the condition. It will create the default handler for the activity as shown below.
STEP 5:-
Now drag and drop the code from the toolbox in to the IfElseBranchActivity1 .This will create the code activity where you will specify the condition for your application as shown below.
Repeat the same thing for IfElseBranchActivity2.
STEP 6:-
Now specify the handler for code activity. To specify the handler for the codeactivity1, select codeactivity1 and click on the properties tab. Give the handler name as ValidPostalCode . This will create the default handler for codeactivity1.
Repeat the same step for codeactivity2 as shown below. Give the handler name as InValidPostalCode as shown below.
Here the designing part gets over. Now we will start with the coding part.
In this example we are validating the Postal code based on the user’s Input.
Write the code on the EvaluatePostalCode method for validating the use input. The below is the code for validating the postal code.
private void EvaluatePostalCode(object sender, ConditionalEventArgs e)
{
string USCode = @”^(\d{5}$)|(\d{5}$-\d{4}$)”;
string CanadianCode = @”[ASDFGHJKLXYZ]\d[A-Z]\d[A-Z]\d”;
e.Result = (Regex.IsMatch(_code, USCode) || Regex.IsMatch(_code, CanadianCode));
}
Here we are validating US and Canadian Postal Code.
We are declaring public property which will take the user input.
public string _code = string.Empty;
public string PostalCode
{
get { return _code; }
set { _code = value; }
}
I will provide the message to be displayed after validating the user input. For that write the code as shown below.
private void ValidPostalCode(object sender, EventArgs e)
{
Console.WriteLine(“The postal code {0} is valid”, _code);
}
private void InValidPostalCode(object sender, EventArgs e)
{
Console.WriteLine(“The postal code {0} is Invalid”, _code);
}
When you create a project one default file by name Program.cs is created in the solution. It contains the static main method created to run your application. Modify the code as per the requirement.
Add the below code just above the WorkFlowInsance.
Dictionary<string, object> dict = new Dictionary<string, object>();
dict.Add(“PostalCode”, args.Length > 0 ? args[0] : “”);
Modify the WorkFlowInsance code as shown below.
WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(WWF_Example.Workflow1), dict);
Build the example by selecting Debug -> build <application>
Now it is the time to test the application. To test the application open the command prompt and navigate to the Debug folder which is located in your application folder and then type
<application name> 12345 (e.g. WWF_Example 12345) as shown below.
That’s it. It will test whether the postal code is valid or invalid.
To download the source code Click here.














Black Hair Care said
Me too, thanks for sharing this..
laer tysk said
Concise and written well, tyvm for the info
Kiev escort girls said
Intresting aricles your placed in this topic. It will be useful to find anything more concerning this article. Thanks for inform that information. Lena! With best regards!
phentermine without prescription said
Useful information shared I’m really pleased to see this particular post..thanks for providing people wonderful tips.Great walk-through. I truly appreciate this post.