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.

Property

Initial Value

Name

"WorkflowRuntime"

IsStarted

false

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(dataService);
        dataService.AddService(expenseService);

        workflowRuntime.AddService(new SqlWorkflowPersistenceService(connectionString));
        workflowRuntime.StartRuntime();

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

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

        waitHandle.WaitOne();

        workflowRuntime.StopRuntime();
    }
}

.NET Framework
Available since 3.0
Return to top
Show: