You are on page 1of 19

Windows workflow foundation 4.

0
Overview and Demo Click to edit Master subtitle style

4/20/12

Summary

Windows Workflow Foundation (WF) provides the declarative framework for building application and service logic and gives developers a higher level language for handling asynchronous, parallel tasks and other complex processing. WF is a set of tools that does the following:

Declares a workflow (your business logic) activities to help express logic and

4/20/12 Defines

Whats New in WF 4.0

New VS Designer - Usability and performance were key goals for the VS 2010 release. Data Flow- WF4 provides a clear, concise model for data flow and scoping for the use of arguments and variables.

Flowchart-Closely resembles the concepts and thought processes that 4/20/12 many analysts and developers go

Whats New in WF 4.0 p2

Programming Model - Activity is the core base type in the programming model and represents both workflows and activities WCF Can now both create services and consume/coordinate service interactions Misc Faster, Breakpoints, Tracing, Notifications and compatible with AppFabric and Azure

4/20/12

Workflow in .NET 4

Visual method for constructing applications Server resources minimized


WFs

can sleep and be rehydrated when needed

Provide ability to coordinate and synchronize internal and external services WF state can be persisted debugging and monitoring

Rich 4/20/12

Workflow Components

Workflow Types
Sequence Flowchart

Execution of activities going forward only Executes like a sequence but allows for return to earlier steps

Standard Activities
Built-in

to WF library (Base Activity Library)

Activity 4/20/12

Base Classes

Activity Library

Microsoft uses WF for its tools BAL Extensive list of existing base activities Create your own activities

4/20/12

Base Activity Library

Control Flow

Sequence, If, Switch, DoWhile, Parallel, ForEach, ParallelForEach, Pick

Flowchart Flowchart, FlowDecision, FlowSwitch Messaging ReceiveAndSendReply,


SendAndReceiveReply, Send, Receive, CorrelationScope, InitializeCorrelation

Runtime Persist, TerminateWorkflow Primitives Assign, Delay, InvokeMethod, WriteLine Transactions TransScope, CompensableActivity,
Compensate, Confirm, CancelScope

Collections AddToColl, RemoveFromColl, ExistsIn, 4/20/12

Custom Activities

Activities can be created in three main ways:


As

a composition of other existing activities code pure XAML

In

In
4/20/12

Designing Workflows

When designing or defining workflows, there are two main options: Code or XAML.
XAML

provides the truly declarative experience and allows for the entire definition of your workflow to be defined in XML mark-up developers will likely use the workflow designer to build workflows which will result in a declarative XAML workflow definition.

Most

execute a workflow, all you need is an Activity which can be an instance built in code, or one created from XAML 4/20/12

To

Arguments & Variables

Arguments and variables are unique to each running instance.


They The

can be of any type and used as inputs, outputs, or both input and outputs. visibility or scope of a variable is dependent on where it is declared.
So if a variable is declared inside an activity, it

will be visible to child activities, but not to parent activities.

4/20/12

Transactions

Workflow provides 2 activities to manage transactions


TransactionScope

manages transactions that are created within the current process works with WCF messaging activities to flow transactions that are created by the calling application into the WF service operation.
NOTE: WSHttpBinding, WSHttpContextBinding

TransactionReceiveScope

and NetTcpBinding all support flowing transactions but BasicHttpBinding does not.
4/20/12

Error Handling

TryCatch activity is similar to Try/Catch in C# Catch<T> represents a catch block within the TryCatch activity

4/20/12

Executing Workflows

To execute a workflow, you need an Activity that defines the workflow. There are two typical ways to execute them:
Create Read

it in code by instantiating and calling the workflow invoker in an XAML file and deserialize the content into an Activity and pass to the workflow invoker

4/20/12

Extensibility

Workflow extensions enable the developer writing the host code to add behavior to the runtime by extending it with custom code. Two extension types that the WF runtime is aware of are the persistence and tracking extensions.

4/20/12

Persistence

Persistence enables the host to support long running processes, load balance instances across hosts and other fault tolerant behaviors. There are two ways the workflow can get persisted.
Through

direct use of the Persist activity in a workflow. When this activity executes it causes the workflow state to be persisted to the database, saving the current state of the workflow. This affords the workflow author control over when it is important to save the 4/20/12

Tracking

Having information about what a workflow is currently doing and what it has done is critical to both managing workflows and gaining insight into the business process. Tracking consists of two primary components
Tracking Tracking

participants

profiles. A tracking profile defines what events and data you want the runtime to track. Profiles can include three primary types 4/20/12 queries: of

WCF Integration

WF provides the ability to:


Declaratively

author WCF services

i.e. WF exposed as a WCF service endpoint


Invoke

WCF services from within a workflow

4/20/12

Demo

Demo 1 Sequence Calculator Demo 2 Flowchart Calculator Demo 3 Unit Testing Calculator Demo 4 Review Transaction Workflows Demo 5 Review Parallel/Async Workflows

4/20/12

You might also like