WorkflowInstance 类

定义

WorkflowInstance 是一种基于实例的轻量运行时,用于执行工作流程序。WorkflowInstance is a lightweight, per-instance runtime for executing a workflow program. 可以构造它来创建新工作流实例,或依据现有实例状态来创建它。It can be constructed to create a new workflow instance or from existing instance state. WorkflowInstance.WorkflowInstanceControl公开的 API 是最小运行时控件集,可依据这些控件来实现更高级别的操作。The APIs that WorkflowInstance.WorkflowInstanceControl exposes are the minimal set of runtime controls from which higher level operations can be implemented. 此 API 集表示运行时的整个范围的功能。This API set represents the entire breadth of functionality of the runtime. WorkflowInstance 是一个抽象类,依赖于主机对其抽象方法的实现,以便提供同步、保留、跟踪和扩展等主机功能。WorkflowInstance is an abstract class and relies on a host's implementation of its abstract methods in order to provide host functionality such as synchronization, persistence, tracking, and extensions.

public ref class WorkflowInstance abstract
public abstract class WorkflowInstance
type WorkflowInstance = class
Public MustInherit Class WorkflowInstance
继承
WorkflowInstance
派生

注解

WorkflowInstance 是单线程的,并假定主机同步所有对它的访问。WorkflowInstance is single threaded and assumes that the host synchronizes all access to it. 如果尝试同时调用多个 API,将导致引发 InvalidOperationExceptionAn attempt to call multiple APIs simultaneously will result in an InvalidOperationException being thrown.

WorkflowInstance 在内部有两种状态:“正在运行”和“已暂停”。Internally, a WorkflowInstance has two states: Running and Paused. 使运行时从已暂停状态转换为正在运行状态的唯一方法是调用 RunThe only way to cause the runtime to transition from paused to running is to call Run. 所有操作(除“暂停”外)都只能在运行时处于“已暂停”状态时执行。All actions (except Pause) can only be taken while the runtime is Paused. 在以下情况中,运行时会自然而然地变为“已暂停”状态:The runtime will become spontaneously Paused in the following situations:

  • 运行时发生致命错误。An error fatal to the runtime has occurred. 将通过 OnRequestAbort 向宿主发出信号(不会发出转换为“已暂停”的信号),然后通过 OnNotifyPaused 通知宿主。The host will be signaled through OnRequestAbort (which does not signal a transition to Paused) and then notified through OnNotifyPaused.

  • 工作流中的异常处于未捕获状态,并已将根转义。An exception in the workflow was uncaught and escaped the root. 将通过 OnNotifyUnhandledException 方法通知宿主。The host will be notified through the OnNotifyUnhandledException method.

  • 计划程序已用完工作项,现在为 IdleThe scheduler has run out of work items and is now Idle. 将通过 OnNotifyPaused 方法通知宿主。The host will be notified through the OnNotifyPaused method. 请注意,由于实例处于空闲状态或实例已完成,因此计划程序可能已用完工作项。Note that the scheduler could have run out of work items because the instance is idle or because the instance is complete. 可以使用 State 属性的 Controller 值来区分这两种状态。The State value of the Controller property can be used to differentiate between the two.

宿主可通过调用由 RequestPause 属性返回的 PauseWhenPersistable 实例的 WorkflowInstance.WorkflowInstanceControlController 方法,请求从“正在运行”更改为“已暂停”。The host can request a change from Running to Paused by calling the RequestPause or PauseWhenPersistable methods of the WorkflowInstance.WorkflowInstanceControl instance returned by the Controller property. 不应将此请求视为具有特定的响应含义,即主机不应尝试将 OnNotify* 或 OnRequestAbort 与特定的暂停调用相关联。This request should not be considered to have a specific response meaning that the host should not attempt to correlate an OnNotify* or OnRequestAbort with a specific call to pause. 为响应暂停请求,运行时可转换为“已暂停”,并在计划程序仍然具有挂起的工作项时调用 OnNotifyPausedIn response to a pause request, the runtime may transition to Paused and call OnNotifyPaused while the scheduler still has pending work items. 可以使用 State 属性的 Controller 值来确定计划程序是没有其他工作还是被暂停请求所中断。The State value of the Controller property can be used to determine whether the scheduler has no more work or was interrupted by a request to pause.

RequestPause 处于“正在运行状态”时,只能调用 WorkflowInstance.WorkflowInstanceControl 属性返回的 Controller 实例的 WorkflowInstance 方法。The RequestPause method of the WorkflowInstance.WorkflowInstanceControl instance returned by the Controller property is the only method which can be called while the WorkflowInstance is in the Running state. 调用所有其他方法都会引发 InvalidOperationException。如果存在有关 WorkflowInstance 如何从一种状态转换为另一种状态的规则,则可按以下方式定义“正在运行”和“已暂停”的公共概念:All other methods will throw an InvalidOperationException if called.Given the rules for how WorkflowInstance transitions from one state to another, the public notion of Running and Paused can be defined as follows:

  • 正在运行-调用 Run 和下一 OnNotify * 之间的状态。Running - The state between a call to Run and the next WorkflowInstance.OnNotify*.

  • 已暂停-最后一个 OnNotify * 和下一次调用之间的状态 RunPaused - The state between the last WorkflowInstance.OnNotify* and the next call to Run.

构造函数

WorkflowInstance(Activity)

使用指定的工作流定义初始化 WorkflowInstance 类的新实例。Initializes a new instance of the WorkflowInstance class with the specified workflow definition.

WorkflowInstance(Activity, WorkflowIdentity)

使用指定的工作流定义和定义标识来初始化 WorkflowInstance 类的新实例。Initializes a new instance of the WorkflowInstance class with the specified workflow definition and definition identity.

属性

Controller

获取此 WorkflowInstance.WorkflowInstanceControlWorkflowInstance 实例。Gets the WorkflowInstance.WorkflowInstanceControl instance for this WorkflowInstance.

DefinitionIdentity

获取或设置 WorkflowInstance 的定义标识。Gets or sets the definition identity of WorkflowInstance.

HostEnvironment

获取或设置工作流实例的自变量和变量的根环境。Gets or sets the root environment for the workflow instance's arguments and variables.

Id

获取工作流实例的唯一标识符。Gets the unique identifier for the workflow instance.

IsReadOnly

获取一个值,该值指示工作流实例是否已初始化。Gets a value that indicates whether the workflow instance has been initialized.

SupportsInstanceKeys

获取一个值,该值指示宿主是否支持 InstanceKeys 与运行时实例的关联。Gets a value that indicates whether the host supports the association of InstanceKeys with a run-time instance.

SynchronizationContext

获取或设置用于调度工作流实例的 SynchronizationContextGets or sets the SynchronizationContext used for scheduling the workflow instance.

WorkflowDefinition

获取工作流实例的工作流定义。Gets the workflow definition of the workflow instance.

方法

BeginFlushTrackingRecords(TimeSpan, AsyncCallback, Object)

由工作流运行时调用,用于开始将挂起的跟踪记录以异步方式发送给跟踪参与者。Called by the workflow runtime to begin sending pending tracking records to tracking participants asynchronously.

DisposeExtensions()

对实现 Dispose() 的所有扩展调用 IDisposableCalls Dispose() on all extensions that implement IDisposable.

EndFlushTrackingRecords(IAsyncResult)

由工作流运行时调用,用于结束跟踪操作。Called by the workflow runtime to end the track operation.

Equals(Object)

确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
FlushTrackingRecords(TimeSpan)

由工作流运行时调用,用于将挂起的跟踪记录发送给跟踪参与者。Called by the workflow runtime to send pending tracking records to tracking participants.

GetActivitiesBlockingUpdate(Object, DynamicUpdateMap)

检索阻塞工作流更新的活动列表。Retrieves the list of activity that is blocking the update of the workflow.

GetExtension<T>()

返回指定类型的扩展。Returns an extension of the specified type.

GetExtensions<T>()

返回针对指定类型找到的所有扩展。Returns all extensions found for the specified type.

GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
Initialize(IDictionary<String,Object>, IList<Handle>)

由主机调用,用于使用自变量值和执行属性初始化工作流实例。Called by the host to initialize the workflow instance with the argument values and execution properties.

Initialize(Object)

由宿主调用,用于使用工作流运行时状态初始化工作流实例。Called by the host to initialize the workflow instance with the workflow run-time state.

Initialize(Object, DynamicUpdateMap)

由宿主调用,用于使用工作流运行时状态和更新映射初始化工作流实例。Called by the host to initialize the workflow instance with the workflow run-time state and update map.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
OnBeginAssociateKeys(ICollection<InstanceKey>, AsyncCallback, Object)

由工作流运行时调用,用于通知宿主新的实例键应与此实例关联。Called by the workflow runtime to notify the host that new instance keys should be associated with this instance.

OnBeginFlushTrackingRecords(AsyncCallback, Object)

异步调用,用于要求主机针对跟踪参与者刷新挂起的跟踪记录。Asynchronous call to ask host to flush pending tracking records to tracking participants.

OnBeginPersist(AsyncCallback, Object)

要求宿主保留工作流的异步调用。Asynchronous call to ask the host to persist the workflow.

OnBeginResumeBookmark(Bookmark, Object, TimeSpan, AsyncCallback, Object)

由工作流运行时调用,用于通知宿主恢复书签操作已开始。Called by the workflow runtime to notify the host that a resume bookmark operation is beginning.

OnDisassociateKeys(ICollection<InstanceKey>)

由工作流运行时调用,用于通知宿主某些实例键集不应再与此实例关联。Called by the workflow runtime to notify the host that a certain set of instance keys should no longer be associated with this instance.

OnEndAssociateKeys(IAsyncResult)

由工作流运行时调用,用于通知宿主关联键操作已完成。Called by the workflow runtime to notify the host that an associate keys operation is complete.

OnEndFlushTrackingRecords(IAsyncResult)

由工作流运行时调用,用于在刷新跟踪记录操作完成时通知宿主。Called by the workflow runtime to notify the host when the flush tracking records operation is complete.

OnEndPersist(IAsyncResult)

由工作流运行时调用,用于通知宿主保留操作已完成。Called by the workflow runtime to notify the host that a persist operation is complete.

OnEndResumeBookmark(IAsyncResult)

由工作流运行时调用,用于通知宿主恢复书签操作已完成。Called by the workflow runtime to notify the host that a resume bookmark operation is complete.

OnNotifyPaused()

由工作流运行时调用,用于通知宿主工作流已从“正在运行”状态转换为“已暂停”状态。Called by the workflow runtime to notify the host that the workflow instance has transitioned from the running state to the paused state.

OnNotifyUnhandledException(Exception, Activity, String)

由工作流运行时调用,用于通知宿主工作流实例中发生了未经处理的异常。Called by the workflow runtime to notify the host an unhandled exception has occurred in the workflow instance.

OnRequestAbort(Exception)

由工作流运行时调用,用于通知宿主已请求对工作流实例进行中止操作。Called by the workflow runtime to notify the host that an abort operation has been requested for the workflow instance.

RegisterExtensionManager(WorkflowInstanceExtensionManager)

由主机调用,用于注册指定的扩展管理器、验证所有必需的扩展是否存在,以及初始化要使用的扩展的集合。Called by the host to register the specified extension manager, validate that all required extensions are present, and to initialize the collection of extensions to be used.

ThrowIfReadOnly()

如果工作流实例已初始化,则引发 InvalidOperationException(由 IsReadOnly 确定)。Throws an InvalidOperationException if the workflow instance has been initialized, as determined by IsReadOnly.

ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

适用于