Skip Ribbon Commands
Skip to main content
Using Windows WorkFlow Foundation

WWF How-To's

Custom Activities


"Extensions" are regular classes with public methods and properties used to add functionality to an entire workflow application.  A workflow application can have only one instance of an extension class. 

Extension objects are added to the workflow application using WorkflowApplication.Extensions.Add().  An activity's Execute method can access the extension object by using it's context.GetExtension<TypeOfExtension>() method.

A workflow can add its own extensions in its CacheMetadata method by using the AddDefaultExtensionProvider<T> method of the "metadata" (ActivityMetadata, CodeActivityMetadata, NativeActivityMetadata) input parameter, for example:

protected override void CacheMetadata(NativeActivityMetadata metadata)
    metadata.AddDefaultExtensionProvider(() => new MyExtension());



WWF Data Model - includes info on Variables, Arguments and Expressions



Rehosting the WWF Designer


WWF and AppFabric


Launching a Workflow

    • Basically, there are two ways to run a workflow: use workflowinvoker.invoke or create a new workflowapplication. creating a new workflowapplication is more useful and allows us to access a wider range of features, including handling exceptions which occur in the workflow and bookmarks
    • Also, there is running a workflow as a service as would be in AppFabric on a server.   Note that the workflow must be set up beforehand to be run as  a workflow service.


Triggered Workflows -- launching a workflow due to external conditions/events


Traversing the Activity Tree that makes up your workflow

Routing in WCF

Manually Converting Workflow to and from XAML

WorkflowMarkupSerializer serializer =
  new WorkflowMarkupSerializer();

using (XmlWriter writer = new XmlTextWriter(
  new StreamWriter("test.xaml")))
  serializer.Serialize(writer, seq);
  • This code will serialize a workflow into the file test.xaml by calling your activity's serializer rather than using the WF default

Writing a free form custom activity


AppFabric Management

Tracking and Logging


Workflows in the Cloud

Tips and Traps