Windows 工作流:从工作流中启动单独的工作流

发布于 2024-07-23 05:17:34 字数 98 浏览 5 评论 0原文

这似乎比我最初猜测的更复杂。 我有一个工作流程需要在代码中启动另一个工作流程。 这是怎么做到的? 我是否必须首先获取对当前工作流实例的 WorkflowRuntime 的引用?

This seems to be more complicated than I first guessed. I have a workflow that needs to kick off another workflow in the code. How is this done? Do I have to get a reference to the current workflow instance's WorkflowRuntime first?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦在深巷 2024-07-30 05:17:34

我认为 InvokeWorkflowActivity 可能是什么你正在寻找。 我已使用它从其他工作流程中启动工作流程,并且效果很好。

请注意,新工作流程(就像所有工作流程一样)是异步执行的,因此“父工作流程”将在启动子工作流程后直接继续执行。

如果您(无论出于何种原因)无法使用 InvokeWorkflowActivity(例如,如果要从父工作流调用的服务内的代码启动新工作流),您将通过一种或另一种方式获取工作流运行时实例。

我处理此场景的方法是在服务接口中声明一个事件,并在将服务添加到运行时时让工作流主机将侦听​​器附加到该事件。 然后,您将拥有一个可以从服务调用的代码点(通过引发事件),它也可以访问运行时; 然后您就拥有了启动新工作流程所需的一切。

I think that the InvokeWorkflowActivity might be what you are looking for. I have used it for launching workflows from within other workflows, and it works well.

Just be aware of the fact that the new workflows (just as all workflows) are executed asynchronously, so the "parent workflow" will continue executing directly after having launched the child workflow.

If you (for whatever reason) can't use the InvokeWorkflowActivity (for instance, if the new workflow is to be started from code within a service which is called from the parent workflow), you will in one way or another get hold of the workflow runtime instance.

The way I have approached this scenario is to declare an event in the service interface, and have the workflow host attach a listener to that event when the service is added to the runtime. Then you will have a code point that can be called from the service (through raising the event), that will also have access to the runtime; then you have all you need to launch the new workflow.

べ映画 2024-07-30 05:17:34

如果您不需要显式活动,则可以使用运行时提供的 IStartWorkflow 服务。

另外,如果您需要同步执行,我会看看这里开始:

http://www.masteringbiztalk.com/blogs/jon/PermaLink,guid,33cfb35c-aca7-4a5e-8b35-ff983b0b83e4.aspx

If you don't need to have an explicit activity, you can make use of the IStartWorkflow service which is available from the runtime.

Also, if you need synchronous execution, I'd take a look here to get started:

http://www.masteringbiztalk.com/blogs/jon/PermaLink,guid,33cfb35c-aca7-4a5e-8b35-ff983b0b83e4.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文