icrosoft Windows Workflow Foundation (WF) consists of a programming model, an engine, and several tools for building workflow-enabled applications. The programming model resides in the System.Workflow namespace of Microsoft's .NET framework 3.0, and has three major classes: Workflow.Activities, Workflow.ComponentModel, and Workflow.Runtime. You can host the workflow engine in any .NET Framework process.
WF Availability and Tools
WF is part of .NET Framework 3.0, which used to be called WinFX. As such, it is currently undergoing a public beta test, for which a GoLive license is available. You only need to sign a GoLive license if you want to deploy
your WF application prior to the production release, but you can develop and test applications with the betas without a license. You can download WF from Microsoft's Web site; links to the latest download can be found on the Windows Workflow Foundation
To use WF from Visual Studio 2005, you'll need the Microsoft Visual Studio 2005 Extensions for Windows Workflow Foundation, which is a separate download from Windows Workflow Foundation itself. The extensions include graphical workflow and custom activity designers for C# and Visual Basic as well as workflow debugger extensions.
In addition to the Visual Studio Extensions, WF has two command-line tools. Wca.exe is the workflow communication activity command line utility, and Wfc.exe is the workflow command line compiler, which compiles both workflows and activities.
Flowcharts and workflows
You can think of WF workflows as executable flowcharts. Historically, systems analysts created flowcharts of system logic using standard symbols (see Figure 1), which programmers would use for guidance when coding the logic manually.
|Figure 1. A Simple Flowchart: This Visio flowchart illustrates several common programming design symbols.||
|Figure 2. Classic Invoice Workflow Diagram: The diagram shows the flow of an invoice through a typical business.||
Modern practice often combines the roles of systems analyst and programmer. Experienced programmers in this dual role often skip the flowcharting step entirely and write directly in code, or create planning documents that are more closely related to the design methodology in use at their shop. Even when designers or developers do
create flowcharts at the beginning of a project, the flowcharts often fall out of synch with the actual code during the course of development, as programmers rarely have time to update what often seems to be irrelevant documentation.
Historically, program designers used workflow diagrams similar to the one in Figure 2 to describe the "flow of control" of a business process. For example, you can easily represent the following common business process in a workflow diagram:
- A contractor provides an invoice for the accounts payable (AP) department.
- AP verifies that the invoice is against a valid purchase order (PO) issued by the purchasing department.
- AP submits the invoice to the approver for the PO.
- If the invoice is approved, AP pays the invoice on the schedule specified in the PO.
Flowcharts do a good job of modeling sequential programs with decision logic, but they don't do a good job of modeling complex event-driven systemssuch as the payment workflow just described. Note that the diagram shows only the most common flowit doesn't take into account either failure at any point during the process, nor does it model the time involved, which might be as little as a day, or as long as several months. For modeling complex event-driven processes people often use state machines. To model the business process above as a state machine, one would list the possible states and the events that trigger state transitions. These states might be Waiting for Invoice
, Invoice Pending
, Invoice Rejected
, Invoice Approved
, Invoice Payable
, Payment Sent
, and Invoice Paid
. The events might be On Invoice Presented
, On PO Valid
, On PO Invalid
, On Invoice Approved
, On Invoice Not Approved
, On Insufficient Funds
, On Invoice Aged
, and On Payment Cleared
As you'll see, Windows Workflow Foundation is capable of modeling both sequential flows and state machines.