Windows Workflow Foundation (WF)

Windows Workflow Foundation (WF) is a Microsoft technology that allows developers to create and manage dynamic workflows and business processes within applications. It provides a programming model, a runtime engine, and tools for designing, executing, and managing workflows.

Key Concepts

Getting Started

To start developing with Windows Workflow Foundation, you will typically use Visual Studio. The .NET Framework 3.5 SDK includes the necessary libraries and tools.

Here's a simple example of a sequential workflow that prints a message:


using System;
using System.Collections.Generic;
using System.Workflow.Activities;
using System.Workflow.ComponentModel;

// Define a simple custom activity
public class GreetActivity : Activity
{
    public InArgument Name { get; set; }

    protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
    {
        Console.WriteLine($"Hello, {Name.Get(executionContext)}!");
        return ActivityExecutionStatus.Closed;
    }
}

// Define the main workflow
public class MyWorkflow : SequentialWorkflowActivity
{
    public MyWorkflow()
    {
        Activities.Add(new GreetActivity { Name = new InArgument("World") });
        Activities.Add(new WriteLine { Text = "Workflow completed." });
    }
}

// Example of how to run the workflow
public class Program
{
    public static void Main(string[] args)
    {
        MyWorkflow workflow = new MyWorkflow();
        workflow.Run();
    }
}
            

Benefits of WF

Note: While WF was a powerful technology in .NET Framework 3.5, for new development in .NET Core and .NET 5+, consider using Durable Functions or other modern orchestration solutions.

Resources