Export (0) Print
Expand All

WorkflowInstance.Abort Method

Aborts the workflow instance.

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

public void Abort()

ExceptionCondition
InvalidOperationException

The workflow runtime engine is not running.

The workflow instance is aborted in a synchronous manner; that is, the method returns after the workflow instance has been aborted. The workflow runtime engine invalidates the workflow instance in memory and clears the WorkBatch. If a persistence service was used by your workflow instance, all work performed since the last persistence point is thrown away. After it aborts the workflow instance, the workflow runtime engine raises the WorkflowAborted event. You can call GetWorkflow to reload the workflow instance and start from its last persistence point.

Abort is different from Terminate in that while Abort simply clears the in-memory workflow instance and can be restarted from the last persistence point, Terminate clears the in-memory workflow instance and informs the persistence service that the instance has been cleared from memory. For the SqlWorkflowPersistenceService, this means that all state information for that workflow instance is deleted from the database upon termination. You will not be able to reload the workflow instance from a previously stored persistence point.

The following example demonstrates calling Abort on a workflow instance of type Workflow1.

//Create a workflow runtime
WorkflowRuntime workflowRuntime = new WorkflowRuntime();
//Create a workflow instance
WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(Workflow1));
//Start the instance
instance.Start();
//Abort the instance
instance.Abort();

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft