WorkflowInstance WorkflowInstance WorkflowInstance WorkflowInstance Class

Definition

Warning

This API is now obsolete.

Represents a workflow instance.

public ref class WorkflowInstance sealed
[System.Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
public sealed class WorkflowInstance
type WorkflowInstance = class
Public NotInheritable Class WorkflowInstance
Inheritance
WorkflowInstanceWorkflowInstanceWorkflowInstanceWorkflowInstance
Attributes

Examples

The following code example demonstrates how you can create and start a WorkflowInstance in a workflow host. The code creates an instance of the WorkflowRuntime, adds services to the runtime, and then demonstrates the recommended way to create a WorkflowInstance object. The code initializes WorkflowInstance by calling the CreateWorkflow method and passing the previously created type to it. The WorkflowInstance is started with the Start method call.

This code example is part of the Canceling a Workflow SDK sample from the Program.cs file. For more information, see Canceling a Workflow.

Type type = typeof(SampleWorkflow1);
WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(type);
workflowInstance.Start();
Dim workflowInstance As WorkflowInstance
workflowInstance = workflowRuntime.CreateWorkflow(GetType(SampleWorkflow))
workflowInstance.Start()

Remarks

Note

This material discusses types and namespaces that are obsolete. For more information, see Deprecated Types in Windows Workflow Foundation 4.5.

The WorkflowInstance class exposes methods and properties that can be used to control the execution of a workflow instance; it is essentially a proxy to the actual workflow instance used by the workflow runtime engine. A host or a service can instruct the workflow runtime engine to perform actions on a workflow instance by calling the appropriate methods that are contained in the WorkflowInstance class. If the requested action is not valid, for example, if the host calls Load on a workflow instance that has already completed, the workflow runtime engine will raise an appropriate exception.

Note

If a workflow instance becomes unresponsive because a call on the host application does not return, the only way to recover the instance is to restart the runtime. However, if the instance has been forcibly unloaded, aborted, or suspended, it can be continued by calling the WorkflowInstance.Resume method.

Properties

InstanceId InstanceId InstanceId InstanceId

Gets the unique identifier for the workflow instance.

WorkflowRuntime WorkflowRuntime WorkflowRuntime WorkflowRuntime

Gets the WorkflowRuntime for this workflow instance.

Methods

Abort() Abort() Abort() Abort()

Aborts the workflow instance.

ApplyWorkflowChanges(WorkflowChanges) ApplyWorkflowChanges(WorkflowChanges) ApplyWorkflowChanges(WorkflowChanges) ApplyWorkflowChanges(WorkflowChanges)

Applies changes to the workflow instance specified by the WorkflowChanges object.

EnqueueItem(IComparable, Object, IPendingWork, Object) EnqueueItem(IComparable, Object, IPendingWork, Object) EnqueueItem(IComparable, Object, IPendingWork, Object) EnqueueItem(IComparable, Object, IPendingWork, Object)

Posts a message to the specified workflow queue synchronously.

EnqueueItemOnIdle(IComparable, Object, IPendingWork, Object) EnqueueItemOnIdle(IComparable, Object, IPendingWork, Object) EnqueueItemOnIdle(IComparable, Object, IPendingWork, Object) EnqueueItemOnIdle(IComparable, Object, IPendingWork, Object)

Posts a message to the specified workflow queue when the workflow is idle. EnqueueItemOnIdle(IComparable, Object, IPendingWork, Object) waits until the workflow reaches an idle point and enqueues after verifying that the workflow scheduler is idle (that is, no active operation is being executed).

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

Returns a value that indicates whether the specified object is equal to the WorkflowInstance.

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

Returns the hash code for this workflow instance.

GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
GetWorkflowDefinition() GetWorkflowDefinition() GetWorkflowDefinition() GetWorkflowDefinition()

Retrieves the root activity for this workflow instance.

GetWorkflowNextTimerExpiration() GetWorkflowNextTimerExpiration() GetWorkflowNextTimerExpiration() GetWorkflowNextTimerExpiration()

Returns the next point in time that this WorkflowInstance is scheduled to be delivered a timer message.

GetWorkflowQueueData() GetWorkflowQueueData() GetWorkflowQueueData() GetWorkflowQueueData()

Gets a collection of WorkflowQueueInfo objects that contains the pending items and subscribed activities for the workflow queues associated with this workflow instance.

Load() Load() Load() Load()

Loads a previously unloaded workflow instance.

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

Creates a shallow copy of the current Object.

(Inherited from Object)
ReloadTrackingProfiles() ReloadTrackingProfiles() ReloadTrackingProfiles() ReloadTrackingProfiles()

Reload the tracking profiles for this workflow instance.

Resume() Resume() Resume() Resume()

Resumes execution of a previously suspended workflow instance.

Start() Start() Start() Start()

Starts the execution of the workflow instance.

Suspend(String) Suspend(String) Suspend(String) Suspend(String)

Suspends the workflow instance.

Terminate(String) Terminate(String) Terminate(String) Terminate(String)

Terminates the workflow instance in a synchronous manner.

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

Returns a string that represents the current object.

(Inherited from Object)
TryUnload() TryUnload() TryUnload() TryUnload()

Unloads the workflow instance from memory to the persistence store when the instance is suspended or idle.

Unload() Unload() Unload() Unload()

Unloads the workflow instance from memory to the persistence store. This call blocks until after the currently scheduled work is finished, or the end of a transaction scope.

Applies to

Thread Safety

This type is thread safe.

See also