WorkflowApplication.ResumeBookmark 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
启动操作以恢复书签。
重载
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
必须恢复书签的时间间隔。
返回
书签恢复操作的结果。
示例
以下示例创建一个工作流,该工作流使用创建 Bookmark的 ReadLine
活动。 工作流启动,创建 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
必须恢复书签的时间间隔。
返回
书签恢复操作的结果。
示例
以下示例创建一个工作流,该工作流使用创建 Bookmark的 ReadLine
活动。 工作流启动,创建 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
作为参数传递给书签恢复时调用的方法的对象。
返回
书签恢复操作的结果。
示例
以下示例创建一个工作流,该工作流使用创建 Bookmark的 ReadLine
活动。 工作流启动,创建 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
作为参数传递给书签恢复时调用的方法的对象。
返回
书签恢复操作的结果。
示例
以下示例创建一个工作流,该工作流使用创建 Bookmark的 ReadLine
活动。 工作流启动,创建 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);
注解
书签结果指示恢复操作是成功还是失败。