Export (0) Print
Expand All

WorkflowApplication.ResumeBookmark Method (Bookmark, Object, TimeSpan)

Initiates an operation to resume the specified bookmark, using the specified value and time-out interval. The bookmark to be resumed is previously created by an activity within the workflow instance.

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

public BookmarkResumptionResult ResumeBookmark(
	Bookmark bookmark,
	Object value,
	TimeSpan timeout
)

Parameters

bookmark
Type: System.Activities.Bookmark

The bookmark to resume.

value
Type: System.Object

An object passed as a parameter to the method that is invoked when the bookmark resumes.

timeout
Type: System.TimeSpan

The time interval during which the bookmark must be resumed.

Return Value

Type: System.Activities.BookmarkResumptionResult
The result of the bookmark resumption operation.

The bookmark result indicates whether the resumption operation succeeded or failed.

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, the user's input is gathered and the bookmark is resumed.

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

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft