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 -
- Creating unified application logic.
- Making application logic scalable.
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 -
- System.Activities.* assemblies for new framework components.
- System.Workflow.* assemblies for backward compatible framework components.
Changes in WF4 include -
- Better workflow designer based on WPF.
- WF4 now has a concise model for data flow and scoping by making use of arguments and variables.
- A new FlowChart activity to help define workflow in flowchart model.
- 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.
- Enhanced integration between WCF and WF with new messaging activities, message correlation and fully declarative service definition.
Activities the building blocks for workflow -
- All activities derive from Activity.
- Activity represents a unit of work in a workflow.
- Activity used as a top level entry point is called a workflow.
- 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