ערוך

שתף באמצעות


WorkflowRuntime Class

Definition

Caution

The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*

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

public ref class WorkflowRuntime : IDisposable, IServiceProvider
public 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
[<System.Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")>]
type WorkflowRuntime = class
    interface IServiceProvider
    interface IDisposable
Public Class WorkflowRuntime
Implements IDisposable, IServiceProvider
Inheritance
WorkflowRuntime
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()

Initializes a new instance of the WorkflowRuntime class.

WorkflowRuntime(String)

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

WorkflowRuntime(WorkflowRuntimeSection)

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

Properties

IsStarted

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

Name

Gets or sets the name associated with the WorkflowRuntime.

Methods

AddService(Object)

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

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

Creates a workflow instance by using the specified parameters.

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)

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

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

Creates a workflow instance by using the specified parameters.

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)

Creates a workflow instance by using the specified XmlReader.

Dispose()

Releases the resources used by the WorkflowRuntime.

Equals(Object)

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

(Inherited from Object)
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>()

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

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetLoadedWorkflows()

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

GetService(Type)

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

GetService<T>()

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

GetType()

Gets the Type of the current instance.

(Inherited from Object)
GetWorkflow(Guid)

Retrieves the workflow instance that has the specified Guid.

MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
RemoveService(Object)

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

StartRuntime()

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

StopRuntime()

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

ToString()

Returns a string that represents the current object.

(Inherited from Object)

Events

ServicesExceptionNotHandled

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

Started

Occurs when the workflow run-time engine is started.

Stopped

Occurs when the workflow run-time engine is stopped.

WorkflowAborted

Occurs when a workflow instance is aborted.

WorkflowCompleted

Occurs when a workflow instance has completed.

WorkflowCreated

Occurs when a workflow instance is created.

WorkflowIdled

Occurs when a workflow instance enters the idle state.

WorkflowLoaded

Occurs when the workflow instance is loaded into memory.

WorkflowPersisted

Occurs when the state of a workflow instance is persisted.

WorkflowResumed

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

WorkflowStarted

Occurs when a workflow instance has been started.

WorkflowSuspended

Occurs when a workflow instance is suspended.

WorkflowTerminated

Occurs when a workflow instance is terminated.

WorkflowUnloaded

Occurs when the workflow instance is unloaded from memory.

Extension Methods

GetKeyedService<T>(IServiceProvider, Object)

Get service of type T from the IServiceProvider.

GetKeyedServices(IServiceProvider, Type, Object)

Get an enumeration of services of type serviceType from the IServiceProvider.

GetKeyedServices<T>(IServiceProvider, Object)

Get an enumeration of services of type T from the IServiceProvider.

GetRequiredKeyedService(IServiceProvider, Type, Object)

Get service of type serviceType from the IServiceProvider.

GetRequiredKeyedService<T>(IServiceProvider, Object)

Get service of type T from the IServiceProvider.

CreateAsyncScope(IServiceProvider)

Creates a new AsyncServiceScope that can be used to resolve scoped services.

CreateScope(IServiceProvider)

Creates a new IServiceScope that can be used to resolve scoped services.

GetRequiredService(IServiceProvider, Type)

Get service of type serviceType from the IServiceProvider.

GetRequiredService<T>(IServiceProvider)

Get service of type T from the IServiceProvider.

GetService<T>(IServiceProvider)

Get service of type T from the IServiceProvider.

GetServices(IServiceProvider, Type)

Get an enumeration of services of type serviceType from the IServiceProvider.

GetServices<T>(IServiceProvider)

Get an enumeration of services of type T from the IServiceProvider.

GetFakeLogCollector(IServiceProvider)

Gets the object that collects log records sent to the fake logger.

GetFakeRedactionCollector(IServiceProvider)

Gets the fake redactor collector instance from the dependency injection container.

Applies to

Thread Safety

This type is thread safe.