What's New in Windows Workflow Foundation
Windows Workflow Foundation (WF) in .NET Framework 4 changes several development paradigms from previous versions. Workflows are now easier to create, execute, and maintain, and implement a host of new functionality. For more information about migrating .NET Framework 3.0 and .NET Framework 3.5 workflow applications to use the latest version, see Migration Guidance.
Workflow Activity Model
The activity is now the base unit of creating a workflow, rather than using the SequentialWorkflowActivity or StateMachineWorkflowActivity classes. The Activity class provides the base abstraction of workflow behavior. Activity authors can then implement either CodeActivity for basic custom activity functionality, or NativeActivity for custom activity functionality that uses the breadth of the runtime. Activity is a class used by activity authors to express new behaviors declaratively in terms of other NativeActivity, CodeActivity, AsyncCodeActivity, or DynamicActivity objects, whether they are custom-developed or included in the Built-In Activity Library.
Rich Composite Activity Options
Flowchart is a powerful new control flow activity that allows authors to model arbitrary loops and conditional branching. Flowchart provides an event-driven programming model that was previously only able to be implemented with StateMachineWorkflowActivity. Procedural workflows benefit from new flow-control activities that model traditional flow-control structures, such as TryCatch and Switch<T>.
Expanded Built-In Activity Library
New features of the activity library include:
New flow control activities, such as, DoWhile, Pick, TryCatch, ForEach<T>, Switch<T>, and ParallelForEach<T>.
Activities for manipulating member data, such as Assign and collection activities such as AddToCollection<T>.
Activities for controlling transactions, such as TransactionScope and Compensate.
New messaging activities such as SendContent and ReceiveReply.
Explicit Activity Data Model
.NET Framework 4 includes new options for storing or moving data. Data can be stored in an activity using Variable. When moving data in and out of an activity, specialized argument types are used to determine which direction data is moving. These types are InArgument, InOutArgument, and OutArgument. For more information, see Windows Workflow Foundation Data Model.
Enhanced Hosting, Persistence, and Tracking Options
.NET Framework 4 contains persistence enhancements such as the following:
There are more options for running workflows, including WorkflowServiceHost, WorkflowApplication, and WorkflowInvoker.
Workflow state data can be explicitly persisted using the Persist activity.
A host can persist an ActivityInstance without unloading it.
A workflow can specify no-persist zones while working with data that cannot be persisted, so that persistence is postponed until the no-persist zone exits.
Transactions can be flowed into a workflow using TransactionScope.
Tracking is more easily accomplished using TrackingParticipant.
Tracking to the system event log is provided using EtwTrackingParticipant.
Resuming a pending workflow is now managed using a Bookmark object.
Easier Ability to Extend WF Designer Experience
The new WF Designer is built on Windows Presentation Foundation (WPF) and provides an easier model to use when rehosting the WF Designer outside of Visual Studio and also provides easier mechanisms for creating custom activity designers. For more information, see Customizing the Workflow Design Experience.
Submit and view feedback for