.NET Framework Class Library
WorkflowInstance Class

Represents a workflow instance.

Namespace:  System.Workflow.Runtime
Assembly:  System.Workflow.Runtime (in System.Workflow.Runtime.dll)
Syntax

Visual Basic (Declaration)
Public NotInheritable Class WorkflowInstance
Visual Basic (Usage)
Dim instance As WorkflowInstance
C#
public sealed class WorkflowInstance
Visual C++
public ref class WorkflowInstance sealed
JScript
public final class WorkflowInstance
Remarks

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

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.

Visual Basic
Dim workflowInstance As WorkflowInstance
workflowInstance = workflowRuntime.CreateWorkflow(GetType(SampleWorkflow))
workflowInstance.Start()
C#
Type type = typeof(SampleWorkflow1);
WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(type);
workflowInstance.Start();
Inheritance Hierarchy

System..::.Object
  System.Workflow.Runtime..::.WorkflowInstance
Thread Safety

This type is thread safe.

Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0
See Also

Reference

Other Resources

Tags :


Page view tracker