This documentation is archived and is not being maintained.

WorkflowApplication.GetBookmarks Method (TimeSpan)

Returns the collection of bookmarks for the workflow instance using the specified time-out interval.

Namespace:  System.Activities
Assembly:  System.Activities (in System.Activities.dll)

member GetBookmarks : 
        timeout:TimeSpan -> ReadOnlyCollection<BookmarkInfo> 


Type: System.TimeSpan
The interval in which this method must complete before the operation is canceled and a TimeoutException is thrown.

Return Value

Type: System.Collections.ObjectModel.ReadOnlyCollection(BookmarkInfo)
A read-only collection of bookmarks for the workflow instance.

The following example creates a workflow that uses a ReadLine activity that creates a Bookmark. The workflow is started, and once the Bookmark is created and the workflow goes idle, GetBookmarks() is called. When the workflow is completed, the following output is displayed to the console.

What is your name? BookmarkName: UserName - OwnerDisplayName: ReadLineSteveHello, Steve

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

    protected override void Execute(NativeActivityContext context)
        // Create a Bookmark and wait for it to be resumed.
            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


// Run the workflow.

// Wait for the workflow to go idle and give it a chance
// to create the Bookmark.

// 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());

.NET Framework

Supported in: 4

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.