Share via


WorkflowApplication.GetBookmarks メソッド

定義

ワークフロー インスタンスのブックマークのコレクションを返します。

オーバーロード

GetBookmarks()

ワークフロー インスタンスのブックマークのコレクションを返します。

GetBookmarks(TimeSpan)

指定されたタイムアウト期間を使用して、ワークフロー インスタンスのブックマークのコレクションを返します。

GetBookmarks()

ワークフロー インスタンスのブックマークのコレクションを返します。

public:
 System::Collections::ObjectModel::ReadOnlyCollection<System::Activities::Hosting::BookmarkInfo ^> ^ GetBookmarks();
public System.Collections.ObjectModel.ReadOnlyCollection<System.Activities.Hosting.BookmarkInfo> GetBookmarks ();
member this.GetBookmarks : unit -> System.Collections.ObjectModel.ReadOnlyCollection<System.Activities.Hosting.BookmarkInfo>
Public Function GetBookmarks () As ReadOnlyCollection(Of BookmarkInfo)

戻り値

ワークフロー インスタンスのブックマークの読み取り専用コレクション。

次の例は、ReadLine を作成する Bookmark アクティビティを使用するワークフローを作成します。 ワークフローが開始され、Bookmark が作成されてワークフローがアイドル状態になると、GetBookmarks が呼び出されます。 このワークフローが完了すると、次の出力がコンソールに表示されます。

What is your name?   
BookmarkName: UserName - OwnerDisplayName: ReadLine  
Steve  
Hello, Steve  
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)
{
    // You can also inspect the bookmarks from the Idle handler
    // using e.Bookmarks

    idleEvent.Set();
};

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

// Wait for the workflow to go idle and give it a chance
// to create the Bookmark.
idleEvent.WaitOne();

// Inspect the bookmarks
foreach (BookmarkInfo info in wfApp.GetBookmarks())
{
    Console.WriteLine("BookmarkName: {0} - OwnerDisplayName: {1}",
        info.BookmarkName, info.OwnerDisplayName);
}

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

注釈

この操作が 30 秒以内に完了しない場合、TimeoutException がスローされます。

適用対象

GetBookmarks(TimeSpan)

指定されたタイムアウト期間を使用して、ワークフロー インスタンスのブックマークのコレクションを返します。

public:
 System::Collections::ObjectModel::ReadOnlyCollection<System::Activities::Hosting::BookmarkInfo ^> ^ GetBookmarks(TimeSpan timeout);
public System.Collections.ObjectModel.ReadOnlyCollection<System.Activities.Hosting.BookmarkInfo> GetBookmarks (TimeSpan timeout);
member this.GetBookmarks : TimeSpan -> System.Collections.ObjectModel.ReadOnlyCollection<System.Activities.Hosting.BookmarkInfo>
Public Function GetBookmarks (timeout As TimeSpan) As ReadOnlyCollection(Of BookmarkInfo)

パラメーター

timeout
TimeSpan

操作が取り消されて TimeoutException がスローされるまでに、このメソッドが完了する必要がある期間。

戻り値

ワークフロー インスタンスのブックマークの読み取り専用コレクション。

次の例は、ReadLine を作成する Bookmark アクティビティを使用するワークフローを作成します。 ワークフローが開始され、Bookmark が作成されてワークフローがアイドル状態になると、GetBookmarks が呼び出されます。 このワークフローが完了すると、次の出力がコンソールに表示されます。

What is your name?   
BookmarkName: UserName - OwnerDisplayName: ReadLine  
Steve  
Hello, Steve  
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)
{
    // You can also inspect the bookmarks from the Idle handler
    // using e.Bookmarks

    idleEvent.Set();
};

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

// Wait for the workflow to go idle and give it a chance
// to create the Bookmark.
idleEvent.WaitOne();

// Inspect the bookmarks
foreach (BookmarkInfo info in wfApp.GetBookmarks())
{
    Console.WriteLine("BookmarkName: {0} - OwnerDisplayName: {1}",
        info.BookmarkName, info.OwnerDisplayName);
}

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

適用対象