我有以下代码
AutoResetEvent instanceUnloaded = new AutoResetEvent(false);
WFStepsActivity workflow = WorkflowFactory.Current.BuildWorkflow(workflowinstance, requestinstance.RequestInstanceID);
WorkflowApplication wf = new WorkflowApplication(workflow);
wf.InstanceStore = WFInstanceStore.GetInstanceStore();
WFStepsPersistenceParticipant persist = new WFStepsPersistenceParticipant();
wf.Extensions.Add(persist);
wf.PersistableIdle = (arg) =>
{
return PersistableIdleAction.Unload;
};
wf.Unloaded = (arg) =>
{
log.Info("WFName_" + wfsetting.Name + "_Unloaded and return.");
instanceUnloaded.Set();
};
wf.OnUnhandledException = (arg) =>
{
return UnhandledExceptionAction.Abort;
};
wf.Completed = (arg) =>
{
if (arg.CompletionState == ActivityInstanceState.Closed)
{
persist.WorklflowCompleted = true;
}
};
wf.Run();
instanceUnloaded.WaitOne();
return persist.WorklflowCompleted;
其中 WFStepsActivity 只是我们从设置中构建的 Acitivity 结构。当前工作流在创建书签时结束。
context.CreateBookmark(context.WorkflowInstanceId.ToString(), new System.Activities.BookmarkCallback(OnResumeBookmark));
问题是在创建书签后wf.Completed
永远不会触发。
如果创建了书签,想检查是否触发了完成。
据我所知,如果您取消、终止,将触发 Complete 事件
不是说一旦书签的工作流停止,就会触发这个事件吗?