WorkflowRuntime 类
定义
注意
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
- 继承
-
WorkflowRuntime
- 属性
- 实现
示例
下面的代码示例演示如何使用工作流宿主中的 WorkflowRuntime 功能。The following code example demonstrates how to use WorkflowRuntime functionality from a workflow host. 该代码示例演示如何使用 WorkflowRuntime 构造函数和 AddService、StartRuntime 和 StopRuntime 方法。It provides examples of how to use the WorkflowRuntime constructor and the AddService, StartRuntime, and StopRuntime methods. 该代码还给出了建议采用的方法,即如何使用 WorkflowInstance 方法在工作流主机中创建 CreateWorkflow 对象。The code also shows the recommended way to create a WorkflowInstance object in a workflow host using the CreateWorkflow method. 它还演示如何为 WorkflowCompleted、WorkflowIdled 和 WorkflowTerminated 事件设置事件处理程序。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
注解
备注
本材料讨论的类型和命名空间已废弃不用。This material discusses types and namespaces that are obsolete. 有关详细信息,请参阅 Windows Workflow Foundation 4.5 中弃用的类型。For more information, see Deprecated Types in Windows Workflow Foundation 4.5.
WorkflowRuntime 公开主机应用程序和服务所需的功能来配置和控制工作流运行时引擎,并接收工作流运行时引擎及其任何工作流实例发生更改的通知。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.
构造函数
| WorkflowRuntime() |
初始化 WorkflowRuntime 类的新实例。Initializes a new instance of the WorkflowRuntime class. |
| WorkflowRuntime(String) |
使用应用程序配置文件的指定节初始化 WorkflowRuntime 类的新实例。Initializes a new instance of the WorkflowRuntime class by using the specified section of the application configuration file. |
| WorkflowRuntime(WorkflowRuntimeSection) |
使用指定的 WorkflowRuntime 中的设置初始化 WorkflowRuntimeSection 类的新实例。Initializes a new instance of the WorkflowRuntime class by using the settings in the specified WorkflowRuntimeSection. |
属性
| IsStarted |
获取一个值,该值指示是否已启动工作流运行时引擎。Gets a value that indicates whether the workflow run-time engine has been started. |
| Name |
获取或设置与 WorkflowRuntime 关联的名称。Gets or sets the name associated with the WorkflowRuntime. |
方法
| AddService(Object) |
将指定的服务添加到工作流运行时引擎中。Adds the specified service to the workflow run-time engine. |
| CreateWorkflow(Type) |
使用指定工作流 Type 创建新的工作流实例。Creates a new workflow instance by using the specified workflow Type. |
| CreateWorkflow(Type, Dictionary<String,Object>) |
使用指定工作流 Type 和指定 Dictionary<TKey,TValue> 中的工作流参数创建工作流实例。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) |
使用指定参数创建工作流实例。Creates a workflow instance by using the specified parameters. |
| CreateWorkflow(XmlReader) |
使用指定的 XmlReader 创建工作流实例。Creates a workflow instance by using the specified XmlReader. |
| CreateWorkflow(XmlReader, XmlReader, Dictionary<String,Object>) |
使用指定的 XmlReader 对象和指定的 Dictionary<TKey,TValue> 中的自变量创建工作流实例。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) |
使用指定参数创建工作流实例。Creates a workflow instance by using the specified parameters. |
| Dispose() |
释放由 WorkflowRuntime 占用的资源。Releases the resources used by the WorkflowRuntime. |
| Equals(Object) |
确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object. (继承自 Object) |
| GetAllServices(Type) |
检索实现或派生自指定的 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. (继承自 Object) |
| GetLoadedWorkflows() |
获取一个集合,该集合包含当前加载到内存的所有工作流实例。Gets a collection that contains all the workflow instances currently loaded in memory. |
| GetService(Type) |
从工作流运行时引擎中检索指定的 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() |
获取当前实例的 Type。Gets the Type of the current instance. (继承自 Object) |
| GetWorkflow(Guid) |
检索具有指定 Guid 的工作流实例。Retrieves the workflow instance that has the specified Guid. |
| MemberwiseClone() |
创建当前 Object 的浅表副本。Creates a shallow copy of the current Object. (继承自 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. (继承自 Object) |
事件
| ServicesExceptionNotHandled |
在派生自 WorkflowRuntimeService 类的服务调用 RaiseServicesExceptionNotHandledEvent(Exception, Guid) 时发生。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. |
适用于
线程安全性
此类型是线程安全的。This type is thread safe.