, , . , .
: , - , . , , , ResumeBookmark.
, . - , , , "--", WF.
, , , GetAndSave, ResumeBookmark WF, . , .
. blogpost. , , , - , .
, , , . , GetAndSave, , , , .
, , , .
async/await WF. AFAIK, , .Wait() .Result . , , - , , .
WF , , WF / .
2:
( )
:
public sealed class TriggerDownload : NativeActivity<string>
{
[RequiredArgument]
public InArgument<string> BookmarkName { get; set; }
protected override void Execute(NativeActivityContext context)
{
context.CreateBookmark(BookmarkName.Get(context),
new BookmarkCallback(OnResumeBookmark));
}
protected override bool CanInduceIdle
{
get { return true; }
}
public void OnResumeBookmark(NativeActivityContext context, Bookmark bookmark, object obj)
{
Result.Set(context, (string)obj);
}
}
, .
:
WorkflowApplication wfApp = new WorkflowApplication(<Your WF>);
AutoResetEvent idleEvent = new AutoResetEvent(false);
wfApp.Idle = delegate(WorkflowApplicationIdleEventArgs e)
{
idleEvent.Set();
};
wfApp.Run();
idleEvent.WaitOne();
var result = await Task.Run(() => GetAndSave());
BookmarkResumptionResult result = wfApp.ResumeBookmark(new Bookmark("GetData"), result);
Console.WriteLine("BookmarkResumptionResult: {0}", result);