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.

  • 排程器已用盡工作項目,現在正處於 Idle 狀態。The 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 執行個體的 PauseWhenPersistableWorkflowInstance.WorkflowInstanceControl 方法 (由 Controller 屬性傳回),以要求從「執行中」變更為「已暫停」。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* 或 OnRequestAbortThis 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與下一個 WorkflowInstance. OnNotify * 之間的狀態。Running - The state between a call to Run and the next WorkflowInstance.OnNotify*.

  • 已暫停-最後一個 WorkflowInstance. OnNotify * 與下一次呼叫Run之間的狀態。Paused - 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 的判定擲回 IsReadOnlyThrows an InvalidOperationException if the workflow instance has been initialized, as determined by IsReadOnly.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

適用於