WorkflowInstance.TryUnload Method
Unloads the workflow instance from memory to the persistence store when the instance is suspended or idle.
Assembly: System.Workflow.Runtime (in System.Workflow.Runtime.dll)
| Exception | Condition |
|---|---|
| InvalidOperationException |
There is no persistence service registered with the workflow runtime engine. |
If the workflow instance is idle or suspended, TryUnload uses the persistence service to remove the workflow instance from memory and persist it to a data store. If there is no persistence service registered with the WorkflowRuntime, TryUnload throws an InvalidOperationException. If the workflow instance is successfully persisted, the runtime raises the WorkflowUnloaded event, and returns true. Unload returns false if the workflow instance has already been unloaded, has been terminated, has been aborted, or has already completed.
The host can use TryUnload to reclaim system resources from an idle workflow.
The following example demonstrates using the TryUnload method to unload a workflow when the WorkflowIdled event fires. This example is from the Using Persistence Services SDK sample, from the Program.cs file. For more information, see Using Persistence Services Sample.
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.