WorkflowRuntime WorkflowRuntime WorkflowRuntime WorkflowRuntime Class

Definition

Warning

This API is now obsolete.

Represents the configurable execution environment provided by the workflow run-time engine for workflows.

public ref class WorkflowRuntime : IDisposable, IServiceProvider
[System.Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
public class WorkflowRuntime : IDisposable, IServiceProvider
type WorkflowRuntime = class
    interface IServiceProvider
    interface IDisposable
Public Class WorkflowRuntime
Implements IDisposable, IServiceProvider
Inheritance
WorkflowRuntimeWorkflowRuntimeWorkflowRuntimeWorkflowRuntime
Attributes
Implements

Examples

The following code example demonstrates how to use WorkflowRuntime functionality from a workflow host. It provides examples of how to use the WorkflowRuntime constructor and the AddService, StartRuntime, and StopRuntime methods. The code also shows the recommended way to create a WorkflowInstance object in a workflow host using the CreateWorkflow method. It also shows how to set event handlers for the WorkflowCompleted, WorkflowIdled, and WorkflowTerminated 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();
    }
}
Shared Sub Main()
    Dim connectionString As String = "Initial Catalog=SqlPersistenceService;Data Source=localhost;Integrated Security=SSPI;"
    Using workflowRuntime As New WorkflowRuntime()
        Dim dataService As New ExternalDataExchangeService()
        workflowRuntime.AddService(dataService)
        dataService.AddService(expenseService)

        workflowRuntime.AddService(New SqlWorkflowPersistenceService(connectionString))


        AddHandler workflowRuntime.WorkflowCompleted, AddressOf OnWorkflowCompleted
        AddHandler workflowRuntime.WorkflowTerminated, AddressOf OnWorkflowTerminated
        AddHandler workflowRuntime.WorkflowIdled, AddressOf OnWorkflowIdled
        AddHandler workflowRuntime.WorkflowAborted, AddressOf OnWorkflowAborted


        Dim workflowInstance As WorkflowInstance
        workflowInstance = workflowRuntime.CreateWorkflow(GetType(SampleWorkflow))
        workflowInstance.Start()

        waitHandle.WaitOne()

        workflowRuntime.StopRuntime()
    End Using
End Sub

Remarks

Note

This material discusses types and namespaces that are obsolete. For more information, see Deprecated Types in Windows Workflow Foundation 4.5.

WorkflowRuntime exposes functionality required by a host application and services to configure and control the workflow run-time engine and to be notified of changes to both the workflow run-time engine and any of its workflow instances.

Constructors

WorkflowRuntime() WorkflowRuntime() WorkflowRuntime() WorkflowRuntime()

Initializes a new instance of the WorkflowRuntime class.

WorkflowRuntime(String) WorkflowRuntime(String) WorkflowRuntime(String) WorkflowRuntime(String)

Initializes a new instance of the WorkflowRuntime class by using the specified section of the application configuration file.

WorkflowRuntime(WorkflowRuntimeSection) WorkflowRuntime(WorkflowRuntimeSection) WorkflowRuntime(WorkflowRuntimeSection) WorkflowRuntime(WorkflowRuntimeSection)

Initializes a new instance of the WorkflowRuntime class by using the settings in the specified WorkflowRuntimeSection.

Properties

IsStarted IsStarted IsStarted IsStarted

Gets a value that indicates whether the workflow run-time engine has been started.

Name Name Name Name

Gets or sets the name associated with the WorkflowRuntime.

Methods

AddService(Object) AddService(Object) AddService(Object) AddService(Object)

Adds the specified service to the workflow run-time engine.

CreateWorkflow(Type) CreateWorkflow(Type) CreateWorkflow(Type) CreateWorkflow(Type)

Creates a new workflow instance by using the specified workflow Type.

CreateWorkflow(Type, Dictionary<String,Object>) CreateWorkflow(Type, Dictionary<String,Object>) CreateWorkflow(Type, Dictionary<String,Object>) CreateWorkflow(Type, Dictionary<String,Object>)

Creates a workflow instance by using the specified workflow Type and the arguments to the workflow contained in the specified Dictionary<TKey,TValue>.

CreateWorkflow(Type, Dictionary<String,Object>, Guid) CreateWorkflow(Type, Dictionary<String,Object>, Guid) CreateWorkflow(Type, Dictionary<String,Object>, Guid) CreateWorkflow(Type, Dictionary<String,Object>, Guid)

Creates a workflow instance by using the specified parameters.

CreateWorkflow(XmlReader) CreateWorkflow(XmlReader) CreateWorkflow(XmlReader) CreateWorkflow(XmlReader)

Creates a workflow instance by using the specified XmlReader.

CreateWorkflow(XmlReader, XmlReader, Dictionary<String,Object>) CreateWorkflow(XmlReader, XmlReader, Dictionary<String,Object>) CreateWorkflow(XmlReader, XmlReader, Dictionary<String,Object>) CreateWorkflow(XmlReader, XmlReader, Dictionary<String,Object>)

Creates a workflow instance by using the specified XmlReader objects and the arguments contained in the specified Dictionary<TKey,TValue>.

CreateWorkflow(XmlReader, XmlReader, Dictionary<String,Object>, Guid) CreateWorkflow(XmlReader, XmlReader, Dictionary<String,Object>, Guid) CreateWorkflow(XmlReader, XmlReader, Dictionary<String,Object>, Guid) CreateWorkflow(XmlReader, XmlReader, Dictionary<String,Object>, Guid)

Creates a workflow instance by using the specified parameters.

Dispose() Dispose() Dispose() Dispose()

Releases the resources used by the WorkflowRuntime.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetAllServices(Type) GetAllServices(Type) GetAllServices(Type) GetAllServices(Type)

Retrieves all the services that are added to the workflow run-time engine that implement or derive from the specified Type.

GetAllServices<T>() GetAllServices<T>() GetAllServices<T>() GetAllServices<T>()

Retrieves all the services that are added to the workflow run-time engine that implement or derive from the specified generic type.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetLoadedWorkflows() GetLoadedWorkflows() GetLoadedWorkflows() GetLoadedWorkflows()

Gets a collection that contains all the workflow instances currently loaded in memory.

GetService(Type) GetService(Type) GetService(Type) GetService(Type)

Retrieves a service of the specified Type from the workflow run-time engine.

GetService<T>() GetService<T>() GetService<T>() GetService<T>()

Retrieves a service of the specified generic type from the workflow run-time engine.

GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
GetWorkflow(Guid) GetWorkflow(Guid) GetWorkflow(Guid) GetWorkflow(Guid)

Retrieves the workflow instance that has the specified Guid.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
RemoveService(Object) RemoveService(Object) RemoveService(Object) RemoveService(Object)

Removes the specified service from the workflow run-time engine.

StartRuntime() StartRuntime() StartRuntime() StartRuntime()

Starts the workflow run-time engine and the workflow run-time engine services.

StopRuntime() StopRuntime() StopRuntime() StopRuntime()

Stops the workflow run-time engine and the run-time services.

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Events

ServicesExceptionNotHandled ServicesExceptionNotHandled ServicesExceptionNotHandled ServicesExceptionNotHandled

Occurs when a service that is derived from the WorkflowRuntimeService class calls RaiseServicesExceptionNotHandledEvent(Exception, Guid).

Started Started Started Started

Occurs when the workflow run-time engine is started.

Stopped Stopped Stopped Stopped

Occurs when the workflow run-time engine is stopped.

WorkflowAborted WorkflowAborted WorkflowAborted WorkflowAborted

Occurs when a workflow instance is aborted.

WorkflowCompleted WorkflowCompleted WorkflowCompleted WorkflowCompleted

Occurs when a workflow instance has completed.

WorkflowCreated WorkflowCreated WorkflowCreated WorkflowCreated

Occurs when a workflow instance is created.

WorkflowIdled WorkflowIdled WorkflowIdled WorkflowIdled

Occurs when a workflow instance enters the idle state.

WorkflowLoaded WorkflowLoaded WorkflowLoaded WorkflowLoaded

Occurs when the workflow instance is loaded into memory.

WorkflowPersisted WorkflowPersisted WorkflowPersisted WorkflowPersisted

Occurs when the state of a workflow instance is persisted.

WorkflowResumed WorkflowResumed WorkflowResumed WorkflowResumed

Occurs when execution of a workflow instance is resumed following a suspension.

WorkflowStarted WorkflowStarted WorkflowStarted WorkflowStarted

Occurs when a workflow instance has been started.

WorkflowSuspended WorkflowSuspended WorkflowSuspended WorkflowSuspended

Occurs when a workflow instance is suspended.

WorkflowTerminated WorkflowTerminated WorkflowTerminated WorkflowTerminated

Occurs when a workflow instance is terminated.

WorkflowUnloaded WorkflowUnloaded WorkflowUnloaded WorkflowUnloaded

Occurs when the workflow instance is unloaded from memory.

Applies to

Thread Safety

This type is thread safe.