Windows Workflow Changes Direction: Write New Workflows with .NET 4.0 in Mind

You can tweak your 3.0/3.5 workflows to make the transition to Windows Workflow Foundation (WF) 4.0 a little easier. These guidelines limit the scenarios in which there's no corresponding feature in 4.0.

  1. Create custom activities. Create custom activities instead of code-beside logic in a CodeActivity. There's no CodeActivity in WF 4.0. Remember that the custom activity model also changes, so it's best to move complex code out of the activity into utility libraries or services.
  2. Scope tightly. 4.0 variables are more constrained than 3.0 dependency properties. They no longer use the property bag/dependency property approach but instead are scoped vertically. Choose a variable in a parent activity set retrieved by child activities rather than directly retrieving data from a sibling activity.
  3. Use Windows Communication Foundation (WCF) messaging when there's a choice. The Data Exchange Service (DES) model goes away in WF 4.0: there's no external event model; external communications is through WCF; and WCF interactions will be considerably easier in WF 4.0. For workflows that might transition to 4.0, write them in WF 3.5, and use the Send and Receive activities. However, if you don't yet have WCF in your application or organization, implementing it in WCF 3.5 may be onerous. In this case, use events, and assume you'll rewrite around the new communications approach.
  4. Perform initialization logic in the Activity.Execute method. The signaling model changes in WF 4.0, and there's no Activity.Initialize event. Any setup should be done in the Activity.Execute method.
  5. Use WorkflowInstance.EnqueueOnIdle for queuing. If you're doing manual queuing, which is relatively uncommon, you should use the EnqueueOnIdle method, as this will be the only queuing model supported going forward.
  6. Be careful with data. The tracking and persistence databases are likely to change significantly between 3.5 and 4.0. Holding data only in tracking is hazardous, unless you prepare a strategy for extracting data, such as when a workflow completes. If you're using rules for simple data retrieval for values that should be set outside the workflow, consider holding this data in a configuration file or database. Note that these are preliminary suggestions. Check out my blog for pointers towards Microsoft's formal guidance, as well as tools (as they become available) that will help you transition workflows.
comments powered by Disqus

Featured

  • Using Local AI to Cut Copilot Usage-Based Billing Shock

    After being gobsmacked by the new billing plan using almost all my monthly credits in one or two days, I tried pushing some Copilot-style coding work onto local models in VS Code. What I found was less "free AI" and more "pick your pain": cloud charges on one side, heavy local resource use and long waits on the other.

  • .NET 11 Preview 5 Focuses on Performance, Productivity and Safer Code

    .NET 11 Preview 5 focuses on under-the-hood runtime performance gains, streamlined APIs and language features that reduce boilerplate, plus built‑in security checks and incremental ASP.NET Core and EF Core improvements aimed at everyday developer productivity.

  • VS Code 1.124 Focuses on Agent Autonomy and Parallel Sessions

    Microsoft's June 2026 VS Code update turns on Autopilot by default and adds background sending for agent sessions.

  • Developing Agentic Systems in .NET: From Concept to Code

    ZioNet founder Alon Fliess previews his Visual Studio Live! San Diego session on building true agentic systems in .NET -- covering the cognitive loop, MCP tool integration, multi-agent orchestration and enterprise hosting and governance with the Microsoft Agent Framework.

Subscribe on YouTube