What’s New in WF4 (.NET4 Beta2)

In version 4 of the Microsoft® .NET Framework, Windows Workflow Foundation introduces a significant amount of change from the previous versions of the technology that shipped as part of .NET 3.0 and 3.5.  In fact, the team revisited the core of the programming model, runtime and tooling and has re-architected each one to increase performance and productivity as well as to address the important feedback garnered from customer engagements using the previous versions.  The significant changes made were necessary to provide the best experience for developers adopting WF and to enable WF to continue to be a strong foundational component that you can build on in your applications. I will introduce the high level changes here, and throughout the paper each topic will get more in depth treatment. 

Before I continue, it is important to understand that backwards compatibility was also a key goal in this release.  The new framework components are found primarily in the System.Activities.* assemblies while the backwards compatible framework components are found in the System.Workflow.* assemblies.  The System.Workflow.* assemblies are part of the .NET Framework 4 and provide complete backward compatibility so you can migrate your application to .NET 4 with no changes to your workflow code. Throughout this paper I will use the name WF4 to refer to the new components found in the System.Activities.* assemblies and WF3 to refer to the components found in the System.Workflow.* assemblies. 

  • Designers

One of the most visible areas of improvement is in the workflow designer. Usability and performance were key goals for the team for the VS 2010 release.  The designer now supports the ability to work with much larger workflows without a degradation in performance and designers are all based on Windows Presentation Foundation (WPF), taking full advantage of the rich user experience one can build with the declarative UI framework.  Activity developers will use XAML to define the way their activities look and interact with users in a visual design environment.  In addition, rehosting the workflow designer in your own applications to enable non-developers to view and interact with your workflows is now much easier. 

  • Data Flow

In WF3, the flow of data in a workflow was opaque.  WF4 provides a clear, concise model for data flow and scoping in the use of arguments and variables.  These concepts, familiar to all developers, simplify both the definition of data storage, as well as the flow of the data into and out of workflows and activities.  The data flow model also makes more obvious the expected inputs and outputs of a given activity and improves performance of the runtime as data is more easily managed. 

  • Flowchart

A new control flow activity called Flowchart has been added to make it possible for developers to use the Flowchart model to define a workflow.  The Flowchart more closely resembles the concepts and thought processes that many analysts and developers go through when creating solutions or designing business processes.  Therefore, it made sense to provide an activity to make it easy to model the conceptual thinking and planning that had already been done.  The Flowchart enables concepts such as returning to previous steps and splitting logic based on a single condition, or a Switch / Case logic. 

  • Programming Model

The WF programming model has been revamped to make it both simpler and more robust.  Activity is the core base type in the programming model and represents both workflows and activities.  In addition, you no longer need to create a WorkflowRuntime to invoke a workflow, you can simply create an instance and execute it, simplifying unit testing and application scenarios where you do not want to go through the trouble of setting up a specific environment.  Finally, the workflow  programming model becomes a fully declarative composition of activities, with no code-beside, simplifying workflow authoring.

Sequence s = new Sequence{

    Activities = {

        new WriteLine {Text = "Hello"},

        new Sequence {

            Activities =

            {

                new WriteLine {Text = "Workflow"},

                new WriteLine {Text = "World"}

            }

        }

    }

};

 

  • Windows Communication Foundation (WCF) Integration

The benefits of WF most certainly apply to both creating services and consuming or coordinating service interactions.  A great deal of effort went into enhancing the integration between WCF and WF.  New messaging activities, message correlation, and improved hosting support, along with fully declarative service definition are the major areas of improvement. 

 

A picture in Visual Studio 2010:

posted @ 2010-01-25 22:05  pccai  阅读(329)  评论(0编辑  收藏  举报