Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

WorkflowApplication.Unload Method (TimeSpan)

Persists and unloads a workflow instance using the specified time-out interval.

Namespace:  System.Activities
Assembly:  System.Activities (in System.Activities.dll)
Public Sub Unload ( _
	timeout As TimeSpan _


Type: System.TimeSpan

The interval in which the unload operation must complete before the operation is canceled and a TimeoutException is thrown.

If the workflow instance was previously loaded from persistence, then the same InstanceStore used to load the workflow is used for persistence. If the workflow was created and has not yet been persisted, then an InstanceStore must be configured before calling this method or else an InvalidOperationException is thrown when this method is called.

The following code example is part of the NoPersistScope activity sample. In this example, the workflow is idle and the host application is waiting for user input. If the user chooses to unload, Unload is called. If successful, the workflow is persisted and unloaded from memory.

// single interaction with the user. The user enters a string in the console and that 
// string is used to resume the ReadLine activity bookmark 
static void Interact(WorkflowApplication application, AutoResetEvent resetEvent)
    Console.WriteLine("Workflow is ready for input");
    Console.WriteLine("Special commands: 'unload', 'exit'");

    bool done = false;
    while (!done)
        Console.Write("> ");
        string s = Console.ReadLine();
        if (s.Equals("unload"))
                // attempt to unload will fail if the workflow is idle within a NoPersistZone
                done = true;
            catch (TimeoutException e)
        else if (s.Equals("exit"))
            application.ResumeBookmark("inputBookmark", s);
            done = true;
            application.ResumeBookmark("inputBookmark", s);

.NET Framework

Supported in: 4.5.1, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Windows Phone 8.1, Windows Phone 8, 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.

© 2014 Microsoft. All rights reserved.