Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
WorkflowInstance Class

WorkflowInstance Class

Represents a workflow instance.

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

public sealed class WorkflowInstance

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.

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();

System.Object
  System.Workflow.Runtime.WorkflowInstance

This type is thread safe.

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.

.NET Framework

Supported in: 3.5, 3.0

Community Additions

ADD
Show:
© 2015 Microsoft