Skip to main content

Introduction to Workflow Foundation 4 (WF4)

I finally decided to pick-up my blogging once more. Since I have been trying to learn Windows Workflow Foundation 4 (WF4) I thought I might as well start off with this topic.

WF4 is a development framework that enables you to create a workflow and embed it in a .Net application. It is neither an executable application nor a language. It provides a set of tools for declaring a workflow, activities to create your logic and to define control flow and a runtime for executing the resulting application definition. It also provides services for persistence of state, tracking and bookmarking. You can create your workflow directly in code, in mark-up or in a combination of both.

Workflow provide us with two major advantages -
  1. Creating unified application logic.
  2. Making application logic scalable.

Workflow Authoring styles - Sequential Workflow executes a set of contained activities in a sequential manner.

Workflow Foundation was introduced in the .Net 3.0 and updated in 3.5. In .net 4 it has been completely revamped leaving with us two set of assemblies -

  1. System.Activities.* assemblies for new framework components.
  2. System.Workflow.* assemblies for backward compatible framework components.

Changes in WF4 include -

  1. Better workflow designer based on WPF.
  2. WF4 now has a concise model for data flow and scoping by making use of arguments and variables.
  3. A new FlowChart activity to help define workflow in flowchart model.
  4. A revamped WF programming model with Activity as the core base class that is now fully declarative composition of activities. So no code beside file just the xaml is sufficient.
  5. Enhanced integration between WCF and WF with new messaging activities, message correlation and fully declarative service definition.

Activities the building blocks for workflow -

  1. All activities derive from Activity.
  2. Activity represents a unit of work in a workflow.
  3. Activity used as a top level entry point is called a workflow.
  4. Activity can contain other activities forming a tree like strucutre.

A sample workflow in code would be like as below -

Sequence workflow = new Sequence
{
new Writeline { Text = "Hello" },
new Writeline { Text = "World" }
}

I would be continuing on this topic in the coming weeks highlighting how to use different types of activities to create workflow in code and how to create and use custom activities.

Comments

Popular posts from this blog

Notes on Castle MonoRail

  Sometime back I was doing a small POC on Castle MonoRail. So here are my quick notes on this. MonoRail is an MVC Framework from Castle inspired by ActionPack. MonoRail enforces separation of concerns with Controller handling application flow, models representing data and View taking care of the presentation logic. To work with MonoRail you need Castle Assemblies. It also utilizes nHibernate You can use Castle MonoRail Project Wizard or create the project manually. Project structure – Content Css Images Controllers HomeController.cs Models Views Home \ index.vm Layouts \ Default.vm ...

Workflow Foundation 4 - Part 3 - Data storage and management

This is my third post on WF4. First one was an introductory post on WF4 and in second one we focused on executing workflows. In the this post I am going to focus on the topic of data storage and management. Every business process or flow depends on data. When you think of data there are three elements to it as listed below - Variables - for storing data Arguments - for passing data Expressions - for manipulating data. Let us first look at the variables. Variables are storage locations for data. Variables are declared before using them just like in any other languages like C# or VB.Net. Variables are defined with a specific scope. When you create a variable in an activity the scope of the variable becomes that activity's scope. Variables can also have access modifiers like None, Mapped or ReadOnly. Let us look at an example where we will create two variables and assign a scope to them along with access modifiers. //Declare a sequence activitiy Sequence seqWf = new Sequence(); //de...