Exploring Workflow Foundation Part 1: Custom Activities

I have an idea for a windows workflow foundation application, which could provide an extension to my offline maps application. I am however not completely familiar yet with the detailed workings of workflow foundation, so I’ll need to explore it first.

What will follow are a series of posts about workflow foundation which will describe this exploration. So if you’re interested you can just follow allong.

This first post will describe Custom Activities.

Workflow and workflow activities

Workflow activities can be compared to execution statements in a normal program. Because of this similarity you will find standard activities provided by Microsoft in the Workflow Foundation framework which do things similar to normal program statements:


A complete summary of available activities you can find in the MSDN documentation.

If activities can be compared to program statements, then a wokflow can be compared to a pogram.

Custom activities: ways of implemention

To implement your own custom activity, you have a few options:

  • You can use the CodeActivity
  • You can derive a new class from the Activity base class

This post will explore the second possibility.

Deriving them from System.Workflow.ComponentModel.Activity

I will make this a rather easy post. Instead of re-typing everything about activities which has allready been said (or typed), I will forward you to some articles on the internet doing a much better job then I could ever do in a single post.

Kevin Nayyeri’s post on creating custom activities has a good intro on the basics.

If you would like to know more about the ActivityExecutionContext parameter to the Execute method, you can look at this and this post.

And for those who want to known about the ActivityExecutionStatus return type, read the post Workflow Foundation: The ActivityExecutionStatus

As you can see from Nayyeri’s post, properties are implemented using dependecy properties. Now what are they? Well, a basic introduction is provided by the post Avalon: Understanding DependencyObject and DependencyProperty. Allthough it is about the WPF implementation, its concepts are valid for WF too. Following two posts are about dependency properties in WF: Dependency Property Notes and Activity Binding in Windows Workflow Foundation
The use case for determining when to use dependency properties or regular properties is stated explicitly in this post WF Activities—Defining the Workflow Parameters:

The primary advantage to dependency properties is that they allow binding of property values to instance data at runtime. For example, you can bind the input property of one activity to an output property of another. The actual property values resulting from the binding is determined at runtime. Dependency properties are required when you want to bind properties from one activity to another. However, if you are binding an activity property to a workflow property, the workflow property is not required to be a dependency property.

Well, that’s about it for this post.

In the accompaning code you can find a custom activity I implemented regarding image processing. Hope you find it usefull.


The Code

More Links

Custom activities
Creating Custom Activities
MVP-Submitted: The Power of Custom Workflow Activities
Build Custom Activities To Extend The Reach Of Your Workflows
Custom workflow activities and the PersistOnClose attribute

Activity Databinding
Windows Workflow Foundation Essentials (cont’d) – Enabling Activity Data Binding
Manage application processes with Windows Workflow Foundation

Custom activity unit testing
Unit testing custom workflow activities
Unit Testing Workflow Activities
A Few Interesting Windows Workflow Links – Provides some references to posts about unit testing Workflow Activities


One thought on “Exploring Workflow Foundation Part 1: Custom Activities

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s