This documentation is archived and is not being maintained.

WorkflowRuntime Constructor

Initializes a new instance of the WorkflowRuntime class.

Namespace:  System.Workflow.Runtime
Assembly:  System.Workflow.Runtime (in System.Workflow.Runtime.dll)

public WorkflowRuntime()

The WorkflowRuntime is initialized with the default property values and contains the default core services. To additionally configure the workflow run-time engine, you can add and remove services by using AddService and RemoveService, and you can set Name. After the WorkflowRuntime is configured, call StartRuntime to start the workflow run-time engine and its services.

The following table shows initial property values for an instance of WorkflowRuntime class.


Initial Value





The default core services are DefaultWorkflowCommitWorkBatchService and DefaultWorkflowSchedulerService.

The following code example demonstrates how you can use WorkflowRuntime functionality from a workflow host. It provides an example of how to use the WorkflowRuntime constructor to create an instance of a WorkflowRuntime and access its methods and events.

This code example is part of the Canceling a Workflow sample.

static void Main()
    string connectionString = "Initial Catalog=SqlPersistenceService;Data Source=localhost;Integrated Security=SSPI;";

    using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
        ExternalDataExchangeService dataService = new ExternalDataExchangeService();

        workflowRuntime.AddService(new SqlWorkflowPersistenceService(connectionString));

        workflowRuntime.WorkflowCompleted += OnWorkflowCompleted;
        workflowRuntime.WorkflowTerminated += OnWorkflowTerminated;
        workflowRuntime.WorkflowIdled += OnWorkflowIdled;
        workflowRuntime.WorkflowAborted += OnWorkflowAborted;

        Type type = typeof(SampleWorkflow1);
        WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(type);



.NET Framework

Supported in: 4, 3.5, 3.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.