WorkflowRuntime 类

定义

注意

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

表示工作流运行时引擎为工作流提供的可配置执行环境。

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
继承
WorkflowRuntime
属性
实现

示例

下面的代码示例演示如何使用工作流宿主中的 WorkflowRuntime 功能。 该代码示例演示如何使用 WorkflowRuntime 构造函数和 AddServiceStartRuntimeStopRuntime 方法。 该代码还给出了建议采用的方法,即如何使用 WorkflowInstance 方法在工作流主机中创建 CreateWorkflow 对象。 它还演示如何为 WorkflowCompletedWorkflowIdledWorkflowTerminated 事件设置事件处理程序。

此代码示例是 取消工作流示例的一 部分。

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

注解

注意

本材料讨论的类型和命名空间已废弃不用。 有关详细信息,请参阅 Windows Workflow Foundation 4.5 中弃用的类型

WorkflowRuntime 公开主机应用程序和服务所需的功能来配置和控制工作流运行时引擎,并接收工作流运行时引擎及其任何工作流实例发生更改的通知。

构造函数

WorkflowRuntime()
已过时.

初始化 WorkflowRuntime 类的新实例。

WorkflowRuntime(String)
已过时.

使用应用程序配置文件的指定节初始化 WorkflowRuntime 类的新实例。

WorkflowRuntime(WorkflowRuntimeSection)
已过时.

使用指定的 WorkflowRuntime 中的设置初始化 WorkflowRuntimeSection 类的新实例。

属性

IsStarted
已过时.

获取一个值,该值指示是否已启动工作流运行时引擎。

Name
已过时.

获取或设置与 WorkflowRuntime 关联的名称。

方法

AddService(Object)
已过时.

将指定的服务添加到工作流运行时引擎中。

CreateWorkflow(Type)
已过时.

使用指定工作流 Type 创建新的工作流实例。

CreateWorkflow(Type, Dictionary<String,Object>)
已过时.

使用指定工作流 Type 和指定 Dictionary<TKey,TValue> 中的工作流参数创建工作流实例。

CreateWorkflow(Type, Dictionary<String,Object>, Guid)
已过时.

使用指定参数创建工作流实例。

CreateWorkflow(XmlReader)
已过时.

使用指定的 XmlReader 创建工作流实例。

CreateWorkflow(XmlReader, XmlReader, Dictionary<String,Object>)
已过时.

使用指定的 XmlReader 对象和指定的 Dictionary<TKey,TValue> 中的自变量创建工作流实例。

CreateWorkflow(XmlReader, XmlReader, Dictionary<String,Object>, Guid)
已过时.

使用指定参数创建工作流实例。

Dispose()
已过时.

释放由 WorkflowRuntime 占用的资源。

Equals(Object)
已过时.

确定指定对象是否等于当前对象。

(继承自 Object)
GetAllServices(Type)
已过时.

检索实现或派生自指定的 Type 且添加到工作流运行时引擎的所有服务。

GetAllServices<T>()
已过时.

检索实现或派生自指定的泛型类型且添加到工作流运行时引擎的所有服务。

GetHashCode()
已过时.

作为默认哈希函数。

(继承自 Object)
GetLoadedWorkflows()
已过时.

获取一个集合,该集合包含当前加载到内存的所有工作流实例。

GetService(Type)
已过时.

从工作流运行时引擎中检索指定的 Type 的服务。

GetService<T>()
已过时.

从工作流运行时引擎中检索指定泛型类型的服务。

GetType()
已过时.

获取当前实例的 Type

(继承自 Object)
GetWorkflow(Guid)
已过时.

检索具有指定 Guid 的工作流实例。

MemberwiseClone()
已过时.

创建当前 Object 的浅表副本。

(继承自 Object)
RemoveService(Object)
已过时.

从工作流运行时引擎中移除指定的服务。

StartRuntime()
已过时.

启动工作流运行时引擎和工作流运行时引擎服务。

StopRuntime()
已过时.

停止工作流运行时引擎和运行时服务。

ToString()
已过时.

返回表示当前对象的字符串。

(继承自 Object)

事件

ServicesExceptionNotHandled
已过时.

在派生自 WorkflowRuntimeService 类的服务调用 RaiseServicesExceptionNotHandledEvent(Exception, Guid) 时发生。

Started
已过时.

启动工作流运行时引擎时发生。

Stopped
已过时.

工作流运行时引擎停止后发生。

WorkflowAborted
已过时.

在中止工作流实例时发生。

WorkflowCompleted
已过时.

在完成工作流实例时发生。

WorkflowCreated
已过时.

在创建工作流实例时发生。

WorkflowIdled
已过时.

在工作流实例进入空闲状态后发生。

WorkflowLoaded
已过时.

将工作流实例加载到内存时发生。

WorkflowPersisted
已过时.

在保留工作流的状态时发生。

WorkflowResumed
已过时.

在暂停后继续执行工作流实例时发生。

WorkflowStarted
已过时.

在启动工作流实例后发生。

WorkflowSuspended
已过时.

在挂起工作流实例时发生。

WorkflowTerminated
已过时.

在终止工作流实例时发生。

WorkflowUnloaded
已过时.

从内存卸载工作流实例时发生。

适用于

线程安全性

此类型是线程安全的。