Windows Workflow Foundation (WF) is one of the three pillars in the WinFX library-the new face of the Windows SDK to be released with Windows Vista later this year. The other two constituent parts of the new Windows SDK are Windows Communication Foundation (WCF), formerly known as Indigo, and Windows Presentation Foundation (WPF) formerly codenamed Avalon.
WF is an extensible framework for developing workflow solutions running on the Windows .NET platform. It provides a unified model to create workflow solutions where each step is said to be an "activity." Like controls in a Windows Forms or ASP.NET application, an activity expresses a well-known behavior, and along with the all other constituent activities, describes the semantics of the workflow. An activity is connected to the rest of the system either sequentially (sequential workflow) or through transition states (state-machine workflow). Speaking in programming terms, an activity is a component that codes a behavior, sports an object model (typically, properties and events) and is backed up by .NET code.
Architecturally speaking, WF provides a workflow engine, a .NET managed API, and a visual designer and debugger integrated with Visual Studio 2005. Just as you create your Web pages visually in a tailor-made environment, you compose the steps of your specific workflow in a visual designer and add code-behind workflow components to implement rules and define the business process.
A WF workflow is made of two files-a collection of activities and a code-behind source file. The activity file can be persisted in either of two ways-using an XML-like language called XOML or using a designer class file. The former approach looks like ASP.NET pages, where you have a markup file (the .aspx file) and a code-behind class written in Visual Basic .NET or C#. The latter approach resembles that of Windows Forms, where you have a form's designer class file (for example, form1.designer.vb) to express the structure of the form using auto-generated code and a code-behind class to incorporate the user-defined logic for the form.
By default, the designer approach is used, but you ultimately choose the preferred style by picking up a different item from the list of new items that can be added to a workflow Visual Studio 2005 project. In terms of performance, there's no difference at all between the two models.
The workflow is compiled to an assembly and deployed as any other assembly in a .NET application-in the Bin folder or in the Global Assembly Cache.
In order to invoke workflows, client applications need to first create (or obtain) an instance of the workflow runtime. Exactly one copy of the workflow runtime is allowed per AppDomain. The runtime takes "messages" from the outside world regarding the workflow types to instantiate and manage. You never instantiate a workflow directly using the new operator. Instead, you send a sort of message to the runtime asking it to create and activate an instance of a given workflow type. The lifetime of the workflow is entirely managed by the runtime. In Windows Forms applications, you create the workflow runtime manually in the startup of the application; in Web applications, you obtain the workflow runtime instance to use directly from a HTTP module that must be registered in the web.config file.
Other than managing the lifetime of workflow instances, the workflow runtime provides rich services, including automatic program persistence, thread scheduling, compensating transactions, and runtime inspection and monitoring of program state. Of particular importance are the persistence and the thread scheduling services. The former allows the runtime to remove from memory a workflow that is idle waiting for user input. The workflow is serialized to a storage medium and resumed on demand when the awaited input arrives. The latter is key in ASP.NET to ensure that the results of the workflow are ready before the page renders out so that the page can incorporate and show them to the user.
Fully integrated with Office 12 and SharePoint 2007, WF is the ultimate workflow API for the Windows and .NET 2.0 platform. Future versions of Microsoft flagship products will incorporate workflow capabilities through this API and most third-party vendors are going to update their products on top of WF. That's the way to go, as far as workflow applications on the Windows platform are concerned.