Bookmark クラス

定義

ワークフローまたはアクティビティが再開を受動的に待機できる点を表します。

public ref class Bookmark : IEquatable<System::Activities::Bookmark ^>
[System.Runtime.Serialization.DataContract]
public class Bookmark : IEquatable<System.Activities.Bookmark>
[<System.Runtime.Serialization.DataContract>]
type Bookmark = class
    interface IEquatable<Bookmark>
Public Class Bookmark
Implements IEquatable(Of Bookmark)
継承
Bookmark
属性
実装

次の例では、ReadLine アクティビティを作成します。 実行されると、ReadLine アクティビティは Bookmark を作成し、コールバックを登録してから、Bookmark が再開されるのを待機します。 再開されると、ReadLine アクティビティは Bookmark と一緒に渡されたデータを Result 引数に代入します。

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);  
    }  
}  

次の例では、 アクティビティを使用 ReadLine してユーザーの名前を収集し、コンソール ウィンドウに表示するワークフローが作成されています。 ホスト アプリケーションは入力を収集する実際の作業を実行し、Bookmark を再開することでワークフローに渡します。

Variable<string> name = new Variable<string>  
{  
    Name = "name"  
};  

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

AutoResetEvent syncEvent = new AutoResetEvent(false);  

// Create the WorkflowApplication using the desired  
// workflow definition.  
WorkflowApplication wfApp = new WorkflowApplication(wf);  

// Handle the desired lifecycle events.  
wfApp.Completed = delegate(WorkflowApplicationCompletedEventArgs e)  
{  
    // Signal the host that the workflow is complete.  
    syncEvent.Set();  
};  

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

// Collect the user's name 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.  
wfApp.ResumeBookmark("UserName", Console.ReadLine());  

// Wait for Completed to arrive and signal that  
// the workflow is complete.  
syncEvent.WaitOne();  

ReadLine アクティビティが実行されると、Bookmark という名前の UserName が作成され、ブックマークが再開されるのを待機します。 ホストは必要なデータを収集し、Bookmark を再開します。 ワークフローが再開されると名前が表示されて、完了します。 ブックマークの再開に関して、同期コードは必要ありません。 Bookmark を再開できるのは、ワークフローがアイドルの場合のみです。ワークフローがアイドルではない場合、ResumeBookmark を呼び出すと、ワークフローがアイドルになるまでブロックされます。

注釈

アクティビティは、Bookmark を作成するとアイドル状態になり、Bookmark の再開を待機します。 Bookmark を作成したアクティビティと並行する他のアクティビティがある場合、これらは実行対象としてスケジュールされます。

ブックマークは、ホスト アプリケーションから、ResumeBookmark オーバーロードのいずれかを使用して再開できます。

ブックマークの詳細については、「 WorkflowInvoker と WorkflowApplication とBookmarks の使用」を参照してください。

コンストラクター

Bookmark(String)

指定された名前を使用して、Bookmark クラスの新しいインスタンスを初期化します。

プロパティ

Name

ブックマーク名を取得します。

メソッド

Equals(Bookmark)

現在の Bookmark と指定された Bookmark が、ワークフロー内の同一の継続点を参照するかどうかを判断します。

Equals(Object)

現在の Bookmark と指定されたオブジェクトが、ワークフロー内の同一の継続点を参照するかどうかを判断します。

GetHashCode()

この Bookmark インスタンスの一意の識別子を返します。

GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

名前付きブックマークならブックマーク名、名前なしブックマークならブックマーク ID を返します。

適用対象