并行执行工作流程
我是WF新手,所以请帮助我理解以下内容。 假设我有一个工作流程,它将一些数据作为输入,对其进行处理,然后将其返回。我的任务是并行处理许多数据项。据我了解,工作流的单个实例只能顺序执行,不能并行执行。显然,为每个数据项实例化一个新的工作流是相当昂贵的,所以我首先想到的是创建一个工作流实例池并在并行循环中执行它们?有没有更好的方法来处理此类场景?
I am new to WF, so please help me understand the following.
Let's say I have a Workflow that takes some data as an input, processes it, and returns it back. My task is to process many data items in parallel. As far as I understand, single instance of Workflow can do it only sequentially, not in parallel. Apparently, instantiating a new Workflow for each data item is quite expensive, so first thing that comes into my mind is to create a pool of Workflow instances and execute them in parallel loop? Is there a better way to approach such kind of scenarios?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么你会说实例化一个新的工作流程非常昂贵? WF 本质上是一种方法,如果您在代码中声明它(而不是例如从 XML 加载它),则不会产生任何开销。您可以使用 WorkflowInvoker 类,它提供异步方法来在单独的线程中执行不同的工作流(如果您在执行过程中需要更多信息,例如生命周期事件、书签等,请使用 WorkflowApplication)。
有关详细信息,请参阅使用 WorkflowInvoker 和 WorkflowApplication。
Why would you say that instantiating a new workflow is quite expensive? A WF is essentially a method and does not have any overhead if you declare it in code (as opposed to load it form XML, for instance). You can use the WorrkflowInvoker class which provides asyncronous methods to execute different workflows in separate threads (if you need more information during the execution, e.g lifecycle events, bookmark etc. use WorkflowApplication).
See Using WorkflowInvoker and WorkflowApplication for more details.