WorkFlow Foundation 4 WorkflowApplication 已完成的输出为空白
我刚刚开始关注 WF4;我很难理解为什么我的输出在我的工作流程中是空白的。
首先,我有一个包含 Sequence 对象(或 Activity?)的 .xaml;其中又包含一个“FirstCodeActivity”,其中包含以下代码:
public class FirstCodeActivity : NativeActivity
{
public OutArgument<string> FirstCodeHasExecuted { get; set; }
protected override void Execute(NativeActivityContext context)
{
context.CreateBookmark("FirstBookmark", OnResumeBookmark);
}
protected override bool CanInduceIdle
{
get { return true; }
}
public void OnResumeBookmark(NativeActivityContext context, Bookmark bookmark, object obj)
{
FirstCodeHasExecuted.Set(context, "Yes");
}
}
根据我的理解,设置书签时,这应该在 FirstCodeHasExecuted 属性中返回值“Yes”。
调试时,我可以确认书签事件已成功触发。
这是我的 WF4 初始化代码:
var idleEvent = new AutoResetEvent(false);
var workflowApplication = new WorkflowApplication(new MyWorkFlow())
{
Idle = delegate { idleEvent.Set(); },
Completed = delegate(WorkflowApplicationCompletedEventArgs e)
{
Outputs = e.Outputs;
}
};
workflowApplication.Run();
idleEvent.WaitOne();
workflowApplication.ResumeBookmark("FirstBookmark", "Resume me!");
idleEvent.WaitOne();
我的问题是我可以理解为什么 e.Outputs 在其字典中不返回任何项目,即使我在 FirstCodeActivity 中设置了该属性。
我在这件事上做错了吗?我的第一个想法是该序列作为不同的上下文运行,因此不包含 FirstCodeActivity 的输出。
任何帮助将不胜感激。
马特
I have just started wrapping my head around WF4; and I'm struggling to understand why my outputs are blank within my workflow.
First, I have an .xaml that contains a Sequence object (or Activity?); which in turn contains a "FirstCodeActivity", which contains the following code:
public class FirstCodeActivity : NativeActivity
{
public OutArgument<string> FirstCodeHasExecuted { get; set; }
protected override void Execute(NativeActivityContext context)
{
context.CreateBookmark("FirstBookmark", OnResumeBookmark);
}
protected override bool CanInduceIdle
{
get { return true; }
}
public void OnResumeBookmark(NativeActivityContext context, Bookmark bookmark, object obj)
{
FirstCodeHasExecuted.Set(context, "Yes");
}
}
From my understanding, this should return the value "Yes" within the FirstCodeHasExecuted property when the bookmark is set.
When debugging, I can confirm that the bookmark event is successfully fired.
Here is my WF4 initialisation code:
var idleEvent = new AutoResetEvent(false);
var workflowApplication = new WorkflowApplication(new MyWorkFlow())
{
Idle = delegate { idleEvent.Set(); },
Completed = delegate(WorkflowApplicationCompletedEventArgs e)
{
Outputs = e.Outputs;
}
};
workflowApplication.Run();
idleEvent.WaitOne();
workflowApplication.ResumeBookmark("FirstBookmark", "Resume me!");
idleEvent.WaitOne();
My issue is that I can understand why e.Outputs returns no items within its dictionary, even though I the property is set within the FirstCodeActivity.
Am I going about this wrong? My first thoughts are that the sequence is run as a different context, and therefore doesn't contain the outputs from the FirstCodeActivity.
Any help would be appreciated.
Matt
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Completed 回调中的输出字典包含工作流中的 OutArguments,而不是作为工作流一部分执行的活动。如果您想在那里查看活动的结果,您需要创建一个工作流程级别 OutArgument 并使用 VB 表达式将 FirstCodeHasExecuted 绑定到该级别。
The Outputs dictionary in the Completed callback contains the OutArguments from the workflow, not activities that execute as part of the workflow. If you want to see the result of your activity there you need to create a workflow level OutArgument and bind the FirstCodeHasExecuted to that using a VB expression.