WorkflowInstance WorkflowInstance WorkflowInstance WorkflowInstance Class

Definition

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. The APIs that WorkflowInstance.WorkflowInstanceControl exposes are the minimal set of runtime controls from which higher level operations can be implemented. This API set represents the entire breadth of functionality of the runtime. 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
Inheritance
WorkflowInstanceWorkflowInstanceWorkflowInstanceWorkflowInstance
Derived

Remarks

WorkflowInstance is single threaded and assumes that the host synchronizes all access to it. An attempt to call multiple APIs simultaneously will result in an InvalidOperationException being thrown.

Internally, a WorkflowInstance has two states: Running and Paused. The 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. 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. The host will be notified through the OnNotifyUnhandledException method.

  • The scheduler has run out of work items and is now Idle. 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. The State value of the Controller property can be used to differentiate between the two.

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. 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. In response to a pause request, the runtime may transition to Paused and call OnNotifyPaused while the scheduler still has pending work items. 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.

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

  • Running - The state between a call to Run and the next WorkflowInstance.OnNotify*.

  • Paused - The state between the last WorkflowInstance.OnNotify* and the next call to Run.

Constructors

WorkflowInstance(Activity) WorkflowInstance(Activity) WorkflowInstance(Activity) WorkflowInstance(Activity)

Initializes a new instance of the WorkflowInstance class with the specified workflow definition.

WorkflowInstance(Activity, WorkflowIdentity) WorkflowInstance(Activity, WorkflowIdentity) WorkflowInstance(Activity, WorkflowIdentity) WorkflowInstance(Activity, WorkflowIdentity)

Initializes a new instance of the WorkflowInstance class with the specified workflow definition and definition identity.

Properties

Controller Controller Controller Controller

Gets the WorkflowInstance.WorkflowInstanceControl instance for this WorkflowInstance.

DefinitionIdentity DefinitionIdentity DefinitionIdentity DefinitionIdentity

Gets or sets the definition identity of WorkflowInstance.

HostEnvironment HostEnvironment HostEnvironment HostEnvironment

Gets or sets the root environment for the workflow instance's arguments and variables.

Id Id Id Id

Gets the unique identifier for the workflow instance.

IsReadOnly IsReadOnly IsReadOnly IsReadOnly

Gets a value that indicates whether the workflow instance has been initialized.

SupportsInstanceKeys SupportsInstanceKeys SupportsInstanceKeys SupportsInstanceKeys

Gets a value that indicates whether the host supports the association of InstanceKeys with a run-time instance.

SynchronizationContext SynchronizationContext SynchronizationContext SynchronizationContext

Gets or sets the SynchronizationContext used for scheduling the workflow instance.

WorkflowDefinition WorkflowDefinition WorkflowDefinition WorkflowDefinition

Gets the workflow definition of the workflow instance.

Methods

BeginFlushTrackingRecords(TimeSpan, AsyncCallback, Object) BeginFlushTrackingRecords(TimeSpan, AsyncCallback, Object) BeginFlushTrackingRecords(TimeSpan, AsyncCallback, Object) BeginFlushTrackingRecords(TimeSpan, AsyncCallback, Object)

Called by the workflow runtime to begin sending pending tracking records to tracking participants asynchronously.

DisposeExtensions() DisposeExtensions() DisposeExtensions() DisposeExtensions()

Calls Dispose() on all extensions that implement IDisposable.

EndFlushTrackingRecords(IAsyncResult) EndFlushTrackingRecords(IAsyncResult) EndFlushTrackingRecords(IAsyncResult) EndFlushTrackingRecords(IAsyncResult)

Called by the workflow runtime to end the track operation.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
FlushTrackingRecords(TimeSpan) FlushTrackingRecords(TimeSpan) FlushTrackingRecords(TimeSpan) FlushTrackingRecords(TimeSpan)

Called by the workflow runtime to send pending tracking records to tracking participants.

GetActivitiesBlockingUpdate(Object, DynamicUpdateMap) GetActivitiesBlockingUpdate(Object, DynamicUpdateMap) GetActivitiesBlockingUpdate(Object, DynamicUpdateMap) GetActivitiesBlockingUpdate(Object, DynamicUpdateMap)

Retrieves the list of activity that is blocking the update of the workflow.

GetExtension<T>() GetExtension<T>() GetExtension<T>() GetExtension<T>()

Returns an extension of the specified type.

GetExtensions<T>() GetExtensions<T>() GetExtensions<T>() GetExtensions<T>()

Returns all extensions found for the specified type.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
Initialize(IDictionary<String,Object>, IList<Handle>) Initialize(IDictionary<String,Object>, IList<Handle>) Initialize(IDictionary<String,Object>, IList<Handle>) Initialize(IDictionary<String,Object>, IList<Handle>)

Called by the host to initialize the workflow instance with the argument values and execution properties.

Initialize(Object) Initialize(Object) Initialize(Object) Initialize(Object)

Called by the host to initialize the workflow instance with the workflow run-time state.

Initialize(Object, DynamicUpdateMap) Initialize(Object, DynamicUpdateMap) Initialize(Object, DynamicUpdateMap) Initialize(Object, DynamicUpdateMap)

Called by the host to initialize the workflow instance with the workflow run-time state and update map.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
OnBeginAssociateKeys(ICollection<InstanceKey>, AsyncCallback, Object) OnBeginAssociateKeys(ICollection<InstanceKey>, AsyncCallback, Object) OnBeginAssociateKeys(ICollection<InstanceKey>, AsyncCallback, 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) OnBeginFlushTrackingRecords(AsyncCallback, Object) OnBeginFlushTrackingRecords(AsyncCallback, Object) OnBeginFlushTrackingRecords(AsyncCallback, Object)

Asynchronous call to ask host to flush pending tracking records to tracking participants.

OnBeginPersist(AsyncCallback, Object) OnBeginPersist(AsyncCallback, Object) OnBeginPersist(AsyncCallback, Object) OnBeginPersist(AsyncCallback, Object)

Asynchronous call to ask the host to persist the workflow.

OnBeginResumeBookmark(Bookmark, Object, TimeSpan, AsyncCallback, Object) OnBeginResumeBookmark(Bookmark, Object, TimeSpan, AsyncCallback, Object) OnBeginResumeBookmark(Bookmark, Object, TimeSpan, AsyncCallback, Object) 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>) OnDisassociateKeys(ICollection<InstanceKey>) OnDisassociateKeys(ICollection<InstanceKey>) 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) OnEndAssociateKeys(IAsyncResult) OnEndAssociateKeys(IAsyncResult) OnEndAssociateKeys(IAsyncResult)

Called by the workflow runtime to notify the host that an associate keys operation is complete.

OnEndFlushTrackingRecords(IAsyncResult) OnEndFlushTrackingRecords(IAsyncResult) OnEndFlushTrackingRecords(IAsyncResult) OnEndFlushTrackingRecords(IAsyncResult)

Called by the workflow runtime to notify the host when the flush tracking records operation is complete.

OnEndPersist(IAsyncResult) OnEndPersist(IAsyncResult) OnEndPersist(IAsyncResult) OnEndPersist(IAsyncResult)

Called by the workflow runtime to notify the host that a persist operation is complete.

OnEndResumeBookmark(IAsyncResult) OnEndResumeBookmark(IAsyncResult) OnEndResumeBookmark(IAsyncResult) OnEndResumeBookmark(IAsyncResult)

Called by the workflow runtime to notify the host that a resume bookmark operation is complete.

OnNotifyPaused() OnNotifyPaused() OnNotifyPaused() 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) OnNotifyUnhandledException(Exception, Activity, String) OnNotifyUnhandledException(Exception, Activity, String) OnNotifyUnhandledException(Exception, Activity, String)

Called by the workflow runtime to notify the host an unhandled exception has occurred in the workflow instance.

OnRequestAbort(Exception) OnRequestAbort(Exception) OnRequestAbort(Exception) OnRequestAbort(Exception)

Called by the workflow runtime to notify the host that an abort operation has been requested for the workflow instance.

RegisterExtensionManager(WorkflowInstanceExtensionManager) RegisterExtensionManager(WorkflowInstanceExtensionManager) RegisterExtensionManager(WorkflowInstanceExtensionManager) 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() ThrowIfReadOnly() ThrowIfReadOnly() ThrowIfReadOnly()

Throws an InvalidOperationException if the workflow instance has been initialized, as determined by IsReadOnly.

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to