This topic has not yet been rated - Rate this topic

WorkflowRuntime Class

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

System.Object
  System.Workflow.Runtime.WorkflowRuntime

Namespace:  System.Workflow.Runtime
Assembly:  System.Workflow.Runtime (in System.Workflow.Runtime.dll)
public class WorkflowRuntime : IServiceProvider, 
	IDisposable

The WorkflowRuntime type exposes the following members.

  Name Description
Public method WorkflowRuntime() Initializes a new instance of the WorkflowRuntime class.
Public method WorkflowRuntime(String) Initializes a new instance of the WorkflowRuntime class by using the specified section of the application configuration file.
Public method WorkflowRuntime(WorkflowRuntimeSection) Initializes a new instance of the WorkflowRuntime class by using the settings in the specified WorkflowRuntimeSection.
Top
  Name Description
Public property IsStarted Gets a value that indicates whether the workflow run-time engine has been started.
Public property Name Gets or sets the name associated with the WorkflowRuntime.
Top
  Name Description
Public method AddService Adds the specified service to the workflow run-time engine.
Public method CreateWorkflow(Type) Creates a new workflow instance by using the specified workflow Type.
Public method CreateWorkflow(XmlReader) Creates a workflow instance by using the specified XmlReader.
Public method 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>.
Public method CreateWorkflow(Type, Dictionary<String, Object>, Guid) Creates a workflow instance by using the specified parameters.
Public method 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>.
Public method CreateWorkflow(XmlReader, XmlReader, Dictionary<String, Object>, Guid) Creates a workflow instance by using the specified parameters.
Public method Dispose Releases the resources used by the WorkflowRuntime.
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetAllServices(Type) Retrieves all the services that are added to the workflow run-time engine that implement or derive from the specified Type.
Public method GetAllServices<T>() Retrieves all the services that are added to the workflow run-time engine that implement or derive from the specified generic type.
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetLoadedWorkflows Gets a collection that contains all the workflow instances currently loaded in memory.
Public method GetService(Type) Retrieves a service of the specified Type from the workflow run-time engine.
Public method GetService<T>() Retrieves a service of the specified generic type from the workflow run-time engine.
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method GetWorkflow Retrieves the workflow instance that has the specified Guid.
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method RemoveService Removes the specified service from the workflow run-time engine.
Public method StartRuntime Starts the workflow run-time engine and the workflow run-time engine services.
Public method StopRuntime Stops the workflow run-time engine and the run-time services.
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Top
  Name Description
Public event ServicesExceptionNotHandled Occurs when a service that is derived from the WorkflowRuntimeService class calls RaiseServicesExceptionNotHandledEvent.
Public event Started Occurs when the workflow run-time engine is started.
Public event Stopped Occurs when the workflow run-time engine is stopped.
Public event WorkflowAborted Occurs when a workflow instance is aborted.
Public event WorkflowCompleted Occurs when a workflow instance has completed.
Public event WorkflowCreated Occurs when a workflow instance is created.
Public event WorkflowIdled Occurs when a workflow instance enters the idle state.
Public event WorkflowLoaded Occurs when the workflow instance is loaded into memory.
Public event WorkflowPersisted Occurs when the state of a workflow instance is persisted.
Public event WorkflowResumed Occurs when execution of a workflow instance is resumed following a suspension.
Public event WorkflowStarted Occurs when a workflow instance has been started.
Public event WorkflowSuspended Occurs when a workflow instance is suspended.
Public event WorkflowTerminated Occurs when a workflow instance is terminated.
Public event WorkflowUnloaded Occurs when the workflow instance is unloaded from memory.
Top

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.

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();
    }
}


.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.

This type is thread safe.

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ