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 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.

    using System.Workflow.Runtime.Tracking;
  2. In the Program class, create a static Int32 field named maxSimultaneousWorkflows, and assign it the value 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.

        new DefaultWorkflowSchedulerService(maxSimultaneousWorkflows));

    For more information on this value and the DefaultWorkflowSchedulerService, see Using DefaultWorkflowSchedulerService.

Compiling the Code

For information about compiling your code, see Compiling the Code.

In Task 2: Configure Runtime Services using App.Config, you 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

Copyright © 2007 by Microsoft Corporation. All rights reserved.
Last Published: 2010-03-04