WorkflowInstance.Unload Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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.
public:
void Unload();
public void Unload();
member this.Unload : unit -> unit
Public Sub Unload ()
Exceptions
There is no persistence service registered with the workflow runtime engine.
Remarks
Unload is synchronous; that is, it returns after completing any action that it performs. If the workflow instance is not idle, the runtime waits until the instance can be interrupted. An instance can only be interrupted after the currently scheduled work item completes; this is typically when the currently running Activity returns from its Execute method. However, if the instance is executing a TransactionScopeActivity, the transaction scope must complete execution before the instance can be interrupted. Unload then uses the persistence service to remove the workflow instance from memory and persists it to a data store. If there is no persistence service registered with the WorkflowRuntime, Unload throws an InvalidOperationException. If the workflow instance is successfully persisted, the runtime raises the WorkflowUnloaded event.
The host can use Unload to reclaim system resources from an idle workflow.