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