WorkflowInstance Class

Represents a workflow instance.

Namespace: System.Workflow.Runtime
Assembly: System.Workflow.Runtime (in system.workflow.runtime.dll)

public sealed class WorkflowInstance
public final class WorkflowInstance
public final class WorkflowInstance
Not applicable.

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.

NoteNote:

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 simply been forcibly unloaded, aborted, or suspended, it can be continued by calling the WorkflowInstance.Resume method.

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(Microsoft.Samples.Workflow.CancelWorkflow.SampleWorkflow);
WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(type);
workflowInstance.Start();

System.Object
  System.Workflow.Runtime.WorkflowInstance

This type is thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show: