Simple Procedural Workflow using Windows Workflow Foundation 4.0

Posted: April 18, 2010 in C#, Programming
Tags: , ,

In this article, i will explain following below in Windows Workflow Foundation 4.0:

  • Simple sequence
  • Variables
  • Arguments
  • if-else activity


First, open your Visual Studio 2010, and create a new project and the template is “Workflow Console Application”


Then… you will see workfow designer, in toolbox, click “sequence” and drag it into workflow designer


In “Arguments tab” add these arguments :

In “Variables Tab” add this :


Then… you will add some activities, just drag them from toolbox, your sequence of activities can be like this :


OK… the workflow is nearly finished ! Last step is writing some code in Program.cs  to add parameters into workflow

Write the code below :

using System;
using System.Activities;
using System.Collections.Generic;

namespace WorkflowConsoleApp

    class Program
        static void Main(string[] args)
            Dictionary<string, object>  d = new Dictionary<string, object>();
            d.Add("param1", 1);
            d.Add("param2", 2);

            WorkflowInvoker.Invoke(new Workflow1(), d);

Code explanation :

To passing parameter to workflow you must use Dictionary, how to add data into dictionary is Add(argument_name, value) … so  i add two datas in dictionary with keys “param1” and “param2” (see arguments name above)


Run the program


You can download the solution here

  1. ValyaS says:

    Thank you for this genesly simplicity :)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s