WorkflowApplication.ResumeBookmark 方法

定義

啟動一項恢復書籤的操作。

多載

名稱 Description
ResumeBookmark(String, Object, TimeSpan)

啟動操作,使用指定值與逾時區間,恢復指定名稱的書籤。 待續行的書籤是先前由工作流程實例中的某個活動建立的。

ResumeBookmark(Bookmark, Object, TimeSpan)

啟動操作以恢復指定的書籤,使用指定的值與逾時間隔。 待續行的書籤是先前由工作流程實例中的某個活動建立的。

ResumeBookmark(Bookmark, Object)

啟動操作以恢復指定的書籤,使用指定的值。 待續行的書籤是先前由工作流程實例中的某個活動建立的。

ResumeBookmark(String, Object)

啟動操作,使用指定值恢復書籤名稱。 待續行的書籤是先前由工作流程實例中的某個活動建立的。

ResumeBookmark(String, Object, TimeSpan)

啟動操作,使用指定值與逾時區間,恢復指定名稱的書籤。 待續行的書籤是先前由工作流程實例中的某個活動建立的。

public:
 System::Activities::BookmarkResumptionResult ResumeBookmark(System::String ^ bookmarkName, System::Object ^ value, TimeSpan timeout);
public System.Activities.BookmarkResumptionResult ResumeBookmark(string bookmarkName, object value, TimeSpan timeout);
member this.ResumeBookmark : string * obj * TimeSpan -> System.Activities.BookmarkResumptionResult
Public Function ResumeBookmark (bookmarkName As String, value As Object, timeout As TimeSpan) As BookmarkResumptionResult

參數

bookmarkName
String

書籤名稱將繼續。

value
Object

一個物件作為參數傳遞給方法,當書籤恢復時會被呼叫。

timeout
TimeSpan

書籤必須在一定時間內恢復。

傳回

這是書籤恢復操作的結果。

範例

以下範例建立一個工作流程,使用 ReadLine 一個活動,該活動會產生一個 Bookmark。 工作流程啟動後,建立 Bookmark 完且工作流程進入閒置狀態後,使用者的輸入會被收集並繼續書籤。

public sealed class ReadLine : NativeActivity<string>
{
    [RequiredArgument]
    public InArgument<string> BookmarkName { get; set; }

    protected override void Execute(NativeActivityContext context)
    {
        // Create a Bookmark and wait for it to be resumed.
        context.CreateBookmark(BookmarkName.Get(context),
            new BookmarkCallback(OnResumeBookmark));
    }

    // NativeActivity derived activities that do asynchronous operations by calling
    // one of the CreateBookmark overloads defined on System.Activities.NativeActivityContext
    // must override the CanInduceIdle property and return true.
    protected override bool CanInduceIdle
    {
        get { return true; }
    }

    public void OnResumeBookmark(NativeActivityContext context, Bookmark bookmark, object obj)
    {
        // When the Bookmark is resumed, assign its value to
        // the Result argument.
        Result.Set(context, (string)obj);
    }
Variable<string> name = new Variable<string>();

Activity wf = new Sequence
{
    Variables = { name },
    Activities =
     {
         new WriteLine
         {
             Text = "What is your name?"
         },
         new ReadLine
         {
             BookmarkName = "UserName",
             Result = new OutArgument<string>(name)
         },
         new WriteLine
         {
             Text = new InArgument<string>((env) =>
                 ("Hello, " + name.Get(env)))
         }
     }
};

// Create a WorkflowApplication instance.
WorkflowApplication wfApp = new WorkflowApplication(wf);

// Workflow lifecycle events omitted except idle.
AutoResetEvent idleEvent = new AutoResetEvent(false);

wfApp.Idle = delegate(WorkflowApplicationIdleEventArgs e)
{
    idleEvent.Set();
};

// Run the workflow.
wfApp.Run();

// Wait for the workflow to go idle before gathering
// the user's input.
idleEvent.WaitOne();

// Gather the user's input and resume the bookmark.
// Bookmark resumption only occurs when the workflow
// is idle. If a call to ResumeBookmark is made and the workflow
// is not idle, ResumeBookmark blocks until the workflow becomes
// idle before resuming the bookmark.
BookmarkResumptionResult result = wfApp.ResumeBookmark("UserName",
    Console.ReadLine());

// Possible BookmarkResumptionResult values:
// Success, NotFound, or NotReady
Console.WriteLine("BookmarkResumptionResult: {0}", result);

備註

書籤結果顯示恢復操作是否成功。

適用於

ResumeBookmark(Bookmark, Object, TimeSpan)

啟動操作以恢復指定的書籤,使用指定的值與逾時間隔。 待續行的書籤是先前由工作流程實例中的某個活動建立的。

public:
 System::Activities::BookmarkResumptionResult ResumeBookmark(System::Activities::Bookmark ^ bookmark, System::Object ^ value, TimeSpan timeout);
public System.Activities.BookmarkResumptionResult ResumeBookmark(System.Activities.Bookmark bookmark, object value, TimeSpan timeout);
member this.ResumeBookmark : System.Activities.Bookmark * obj * TimeSpan -> System.Activities.BookmarkResumptionResult
Public Function ResumeBookmark (bookmark As Bookmark, value As Object, timeout As TimeSpan) As BookmarkResumptionResult

參數

bookmark
Bookmark

書籤可繼續。

value
Object

一個物件作為參數傳遞給方法,當書籤恢復時會被呼叫。

timeout
TimeSpan

書籤必須在一定時間內恢復。

傳回

這是書籤恢復操作的結果。

範例

以下範例建立一個工作流程,使用 ReadLine 一個活動,該活動會產生一個 Bookmark。 工作流程啟動後,建立 Bookmark 完且工作流程進入閒置狀態後,使用者的輸入會被收集並繼續書籤。

public sealed class ReadLine : NativeActivity<string>
{
    [RequiredArgument]
    public InArgument<string> BookmarkName { get; set; }

    protected override void Execute(NativeActivityContext context)
    {
        // Create a Bookmark and wait for it to be resumed.
        context.CreateBookmark(BookmarkName.Get(context),
            new BookmarkCallback(OnResumeBookmark));
    }

    // NativeActivity derived activities that do asynchronous operations by calling
    // one of the CreateBookmark overloads defined on System.Activities.NativeActivityContext
    // must override the CanInduceIdle property and return true.
    protected override bool CanInduceIdle
    {
        get { return true; }
    }

    public void OnResumeBookmark(NativeActivityContext context, Bookmark bookmark, object obj)
    {
        // When the Bookmark is resumed, assign its value to
        // the Result argument.
        Result.Set(context, (string)obj);
    }
Variable<string> name = new Variable<string>();

Activity wf = new Sequence
{
    Variables = { name },
    Activities =
     {
         new WriteLine
         {
             Text = "What is your name?"
         },
         new ReadLine
         {
             BookmarkName = "UserName",
             Result = new OutArgument<string>(name)
         },
         new WriteLine
         {
             Text = new InArgument<string>((env) =>
                 ("Hello, " + name.Get(env)))
         }
     }
};

// Create a WorkflowApplication instance.
WorkflowApplication wfApp = new WorkflowApplication(wf);

// Workflow lifecycle events omitted except idle.
AutoResetEvent idleEvent = new AutoResetEvent(false);

wfApp.Idle = delegate(WorkflowApplicationIdleEventArgs e)
{
    idleEvent.Set();
};

// Run the workflow.
wfApp.Run();

// Wait for the workflow to go idle before gathering
// the user's input.
idleEvent.WaitOne();

// Gather the user's input and resume the bookmark.
BookmarkResumptionResult result = wfApp.ResumeBookmark(new Bookmark("UserName"),
    Console.ReadLine(), TimeSpan.FromSeconds(15));

// Possible BookmarkResumptionResult values:
// Success, NotFound, or NotReady
Console.WriteLine("BookmarkResumptionResult: {0}", result);

備註

書籤結果顯示恢復操作是否成功。

適用於

ResumeBookmark(Bookmark, Object)

啟動操作以恢復指定的書籤,使用指定的值。 待續行的書籤是先前由工作流程實例中的某個活動建立的。

public:
 System::Activities::BookmarkResumptionResult ResumeBookmark(System::Activities::Bookmark ^ bookmark, System::Object ^ value);
public System.Activities.BookmarkResumptionResult ResumeBookmark(System.Activities.Bookmark bookmark, object value);
member this.ResumeBookmark : System.Activities.Bookmark * obj -> System.Activities.BookmarkResumptionResult
Public Function ResumeBookmark (bookmark As Bookmark, value As Object) As BookmarkResumptionResult

參數

bookmark
Bookmark

書籤可繼續。

value
Object

一個物件作為參數傳遞給方法,當書籤恢復時會被呼叫。

傳回

這是書籤恢復操作的結果。

範例

以下範例建立一個工作流程,使用 ReadLine 一個活動,該活動會產生一個 Bookmark。 工作流程啟動後,建立 Bookmark 完且工作流程進入閒置狀態後,使用者的輸入會被收集並繼續書籤。

public sealed class ReadLine : NativeActivity<string>
{
    [RequiredArgument]
    public InArgument<string> BookmarkName { get; set; }

    protected override void Execute(NativeActivityContext context)
    {
        // Create a Bookmark and wait for it to be resumed.
        context.CreateBookmark(BookmarkName.Get(context),
            new BookmarkCallback(OnResumeBookmark));
    }

    // NativeActivity derived activities that do asynchronous operations by calling
    // one of the CreateBookmark overloads defined on System.Activities.NativeActivityContext
    // must override the CanInduceIdle property and return true.
    protected override bool CanInduceIdle
    {
        get { return true; }
    }

    public void OnResumeBookmark(NativeActivityContext context, Bookmark bookmark, object obj)
    {
        // When the Bookmark is resumed, assign its value to
        // the Result argument.
        Result.Set(context, (string)obj);
    }
Variable<string> name = new Variable<string>();

Activity wf = new Sequence
{
    Variables = { name },
    Activities =
     {
         new WriteLine
         {
             Text = "What is your name?"
         },
         new ReadLine
         {
             BookmarkName = "UserName",
             Result = new OutArgument<string>(name)
         },
         new WriteLine
         {
             Text = new InArgument<string>((env) =>
                 ("Hello, " + name.Get(env)))
         }
     }
};

// Create a WorkflowApplication instance.
WorkflowApplication wfApp = new WorkflowApplication(wf);

// Workflow lifecycle events omitted except idle.
AutoResetEvent idleEvent = new AutoResetEvent(false);

wfApp.Idle = delegate(WorkflowApplicationIdleEventArgs e)
{
    idleEvent.Set();
};

// Run the workflow.
wfApp.Run();

// Wait for the workflow to go idle before gathering
// the user's input.
idleEvent.WaitOne();

// Gather the user's input and resume the bookmark.
BookmarkResumptionResult result = wfApp.ResumeBookmark(new Bookmark("UserName"),
    Console.ReadLine());

// Possible BookmarkResumptionResult values:
// Success, NotFound, or NotReady
Console.WriteLine("BookmarkResumptionResult: {0}", result);

備註

書籤結果顯示恢復操作是否成功。

適用於

ResumeBookmark(String, Object)

啟動操作,使用指定值恢復書籤名稱。 待續行的書籤是先前由工作流程實例中的某個活動建立的。

public:
 System::Activities::BookmarkResumptionResult ResumeBookmark(System::String ^ bookmarkName, System::Object ^ value);
public System.Activities.BookmarkResumptionResult ResumeBookmark(string bookmarkName, object value);
member this.ResumeBookmark : string * obj -> System.Activities.BookmarkResumptionResult
Public Function ResumeBookmark (bookmarkName As String, value As Object) As BookmarkResumptionResult

參數

bookmarkName
String

書籤名稱將繼續。

value
Object

一個物件作為參數傳遞給方法,當書籤恢復時會被呼叫。

傳回

這是書籤恢復操作的結果。

範例

以下範例建立一個工作流程,使用 ReadLine 一個活動,該活動會產生一個 Bookmark。 工作流程啟動後,建立 Bookmark 完且工作流程進入閒置狀態後,使用者的輸入會被收集並繼續書籤。

public sealed class ReadLine : NativeActivity<string>
{
    [RequiredArgument]
    public InArgument<string> BookmarkName { get; set; }

    protected override void Execute(NativeActivityContext context)
    {
        // Create a Bookmark and wait for it to be resumed.
        context.CreateBookmark(BookmarkName.Get(context),
            new BookmarkCallback(OnResumeBookmark));
    }

    // NativeActivity derived activities that do asynchronous operations by calling
    // one of the CreateBookmark overloads defined on System.Activities.NativeActivityContext
    // must override the CanInduceIdle property and return true.
    protected override bool CanInduceIdle
    {
        get { return true; }
    }

    public void OnResumeBookmark(NativeActivityContext context, Bookmark bookmark, object obj)
    {
        // When the Bookmark is resumed, assign its value to
        // the Result argument.
        Result.Set(context, (string)obj);
    }
Variable<string> name = new Variable<string>();

Activity wf = new Sequence
{
    Variables = { name },
    Activities =
     {
         new WriteLine
         {
             Text = "What is your name?"
         },
         new ReadLine
         {
             BookmarkName = "UserName",
             Result = new OutArgument<string>(name)
         },
         new WriteLine
         {
             Text = new InArgument<string>((env) =>
                 ("Hello, " + name.Get(env)))
         }
     }
};

// Create a WorkflowApplication instance.
WorkflowApplication wfApp = new WorkflowApplication(wf);

// Workflow lifecycle events omitted except idle.
AutoResetEvent idleEvent = new AutoResetEvent(false);

wfApp.Idle = delegate(WorkflowApplicationIdleEventArgs e)
{
    idleEvent.Set();
};

// Run the workflow.
wfApp.Run();

// Wait for the workflow to go idle before gathering
// the user's input.
idleEvent.WaitOne();

// Gather the user's input and resume the bookmark.
// Bookmark resumption only occurs when the workflow
// is idle. If a call to ResumeBookmark is made and the workflow
// is not idle, ResumeBookmark blocks until the workflow becomes
// idle before resuming the bookmark.
BookmarkResumptionResult result = wfApp.ResumeBookmark("UserName",
    Console.ReadLine());

// Possible BookmarkResumptionResult values:
// Success, NotFound, or NotReady
Console.WriteLine("BookmarkResumptionResult: {0}", result);

備註

書籤結果顯示恢復操作是否成功。

適用於