Workflow 4.0 中的多线程

发布于 2024-10-01 02:14:26 字数 86 浏览 1 评论 0原文

我希望 foreach活动中的每个序列在不同的线程中运行。使用 WWF 4.0 可以实现这一点吗?如果没有,如何在WWF 4.0中实现多线程?

I want each sequence inside a foreach<T> activity running in a different thread. Is this possible by using WWF 4.0? If not, how can I achieve multithreading in WWF 4.0?

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

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

发布评论

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

评论(2

寄与心 2024-10-08 02:14:26

这取决于您正在从事的工作类型。默认情况下,工作流调度程序此时只会执行工作流中的单个活动,没有办法解决这个问题。并行活动同时安排多个子活动,但它们不并行执行。

该规则的一个大例外是 AsyncCodeActivity 类型的活动。一旦调度程序执行一些异步操作,就会执行另一个活动。现在,这最适合 IO 绑定工作,例如数据库访问或网络 IO,但这不是必需的。

因此,为了在工作流程中实现真正的并行性,您需要将并行活动之一与从 AsyncCodeActivity 派生的活动结合使用。

It depends on the kind of work you are doing. By default the workflow scheduler will only execute a single activity in a workflow at the time, no way around that. The parallel activities schedule multiple child activities at the same time but they don't execute in parallel.

The big exception to the rule is AsyncCodeActivity type activities. The scheduler will execute another activity as soon as they are doing some asynchronous stuff. Now this works best with IO bound work like database access or network IO but that is not a requirement.

So to achieve true parallelism in your workflows you need to be use a combination of one of the parallel activities with activities deriving from AsyncCodeActivity.

许仙没带伞 2024-10-08 02:14:26

要实现 foreach 的并行执行,请使用 ParallelForEach

To achieve parallel execution of a foreach, use ParallelForEach.

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