第二次运行子活动
我正在尝试使用 WF3.5 编写自定义 CompositeActivity。类似于 WhileActivity 的东西。
问题是,当我想再次执行子活动时(之前通过对 ActivityExecutionContext.CloseActivity() 的最终调用成功),我收到 InvalidOperationException,并显示以下消息:“活动状态必须为‘初始化’才能执行”。
从调试问题来看,子活动的 ExecutionStatus 似乎已关闭,而其 ExecutionResult 则为 Uninitialized。
但是 ActivityExecutionContext.ExecuteActivity 表示“如果状态为 Closed,则 Activity 被初始化并执行”。
那么为什么我会遇到这个异常以及如何避免它?
谢谢, 朱利安
I am trying to write a custom CompositeActivity using WF3.5. Something like a WhileActivity.
The problem is when I want to execute the child activity again (it previously succeeded with a final call to ActivityExecutionContext.CloseActivity()) I get an InvalidOperationException, with this message: "Activity status must be 'Initialized' for executing".
From debugging the problem, it appears that the child activity's ExecutionStatus is Closed and its ExecutionResult is Uninitialized.
But the MSDN doc for ActivityExecutionContext.ExecuteActivity says that "If the status is Closed, the Activity is initialized and executed".
So why am I getting this exception and how can I avoid it?
Thanks,
Julien
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我找到了答案。复合活动每次想要启动子活动时都需要为子活动创建新的 ActivityExecutionContext。
在新的 ActivityExecutionContext 中执行子 Activity:
活动关闭后进行清理:
I think I found the answer. The composite activity needs to create new ActivityExecutionContext for the child activity every time it wants to start the child activity.
Executing the child activity in a new ActivityExecutionContext:
Cleaning up after the activity is Closed: