Task 1: Configure Runtime Services Using CodeĀ 

Download sample

In this task, you learn how to add services to the Windows Workflow Foundation by using methods that are defined in the WorkflowRuntime class. In this task and in the next task, you only use the DefaultWorkflowSchedulerService class. Starting with Task 3: Use the Windows Workflow Persistence Service, you will learn how to use the other services that are provided by Windows Workflow Foundation.


Although you are encouraged to follow the exercises in a linear manner, it is not required. You can start this exercise by opening the sample project and proceeding to the steps in the following section.

To add runtime services

  1. In the Program file, import the System.Workflow.Runtime.Tracking namespace so that you can use the types in that namespace.

    Imports System.Workflow.Runtime.Tracking
    using System.Workflow.Runtime.Tracking;
  2. In the Program class, create a static Int32 field named maxSimultaneousWorkflows, and assign it the value 1.

    Private Shared maxSimultaneousWorkflows As Integer = 1
    static int maxSimultaneousWorkflows = 1;
  3. In the Main method that is defined in the Program class, add the DefaultWorkflowSchedulerService to the WorkflowRuntime.

    Use the AddService method, and pass the number of maximum simultaneous workflows that the DefaultWorkflowSchedulerService can schedule as a parameter.

    workflowRuntime.AddService(New DefaultWorkflowSchedulerService _
        new DefaultWorkflowSchedulerService(maxSimultaneousWorkflows));

Compiling the Code

  1. Click Start, point to Programs, point to Microsoft .NET Framework SDK v2.0, and then click SDK Command Prompt.

  2. Go to the source directory of the tutorial.

  3. At the command prompt, type MSBUILD to build the project.

In the next task, Task 2: Configure Runtime Services using App.Config, you will use an application configuration file to add services to the Windows Workflow Foundation.

See Also




How to: Add and Remove Workflow Services

Other Resources

Task 2: Configure Runtime Services using App.Config

Footer image

Send comments about this topic to Microsoft.