WorkflowApplication.Unload 方法

定义

持久保存和卸载工作流实例。

重载

名称 说明
Unload(TimeSpan)

使用指定的超时间隔持久保存和卸载工作流实例。

Unload()

持久保存和卸载工作流实例。

注解

默认情况下,卸载操作必须在 30 秒内完成或 TimeoutException 引发。

如果以前从持久性加载工作流实例,则用于加载工作流的相同 InstanceStore 用于暂留。 如果工作流已创建且尚未持久化,则在调用此方法之前必须配置一个 InstanceStore 工作流,否则在调用此方法时将引发一个 InvalidOperationException 工作流。

Unload(TimeSpan)

使用指定的超时间隔持久保存和卸载工作流实例。

public:
 void Unload(TimeSpan timeout);
public void Unload(TimeSpan timeout);
member this.Unload : TimeSpan -> unit
Public Sub Unload (timeout As TimeSpan)

参数

timeout
TimeSpan

卸载操作必须在取消和 TimeoutException 引发操作之前完成的间隔。

示例

在此示例中,工作流处于空闲状态,主机应用程序正在等待用户输入。 如果用户选择卸载, Unload 则调用。 如果成功,工作流将持久保存并从内存中卸载。

// 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"))
        {
            try
            {
                // attempt to unload will fail if the workflow is idle within a NoPersistZone
                application.Unload(TimeSpan.FromSeconds(5));
                done = true;
            }
            catch (TimeoutException e)
            {
                Console.WriteLine(e.Message);
            }
        }
        else if (s.Equals("exit"))
        {
            application.ResumeBookmark("inputBookmark", s);
            done = true;
        }
        else
        {
            application.ResumeBookmark("inputBookmark", s);
        }
    }
    resetEvent.WaitOne();
}

注解

如果以前从持久性加载工作流实例,则用于加载工作流的相同 InstanceStore 用于暂留。 如果工作流已创建且尚未持久化,则在调用此方法之前必须配置一个 InstanceStore 工作流,否则在调用此方法时将引发一个 InvalidOperationException 工作流。

适用于

Unload()

持久保存和卸载工作流实例。

public:
 void Unload();
public void Unload();
member this.Unload : unit -> unit
Public Sub Unload ()

示例

在此示例中,工作流处于空闲状态,主机应用程序正在等待用户输入。 如果用户选择卸载, Unload 则调用。 如果成功,工作流将持久保存并从内存中卸载。

// 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"))
        {
            try
            {
                // attempt to unload will fail if the workflow is idle within a NoPersistZone
                application.Unload(TimeSpan.FromSeconds(5));
                done = true;
            }
            catch (TimeoutException e)
            {
                Console.WriteLine(e.Message);
            }
        }
        else if (s.Equals("exit"))
        {
            application.ResumeBookmark("inputBookmark", s);
            done = true;
        }
        else
        {
            application.ResumeBookmark("inputBookmark", s);
        }
    }
    resetEvent.WaitOne();
}

注解

默认情况下,卸载操作必须在 30 秒内完成或 TimeoutException 引发。

如果以前从持久性加载工作流实例,则用于加载工作流的相同 InstanceStore 用于暂留。 如果工作流已创建且尚未持久化,则在调用此方法之前必须配置一个 InstanceStore 工作流,否则在调用此方法时将引发一个 InvalidOperationException 工作流。

适用于