Task 1: Configure Runtime Services Using Code
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
In the Program file, import the System.Workflow.Runtime.Tracking namespace so that you can use the types in that namespace.
In the Program class, create a static Int32 field named maxSimultaneousWorkflows, and assign it the value 1.
static int maxSimultaneousWorkflows = 1;
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(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.
Copyright © 2007 by Microsoft Corporation. All rights reserved.
Last Published: 2010-03-04