Yuriy Magurdumov
Yuriy Magurdumov

Reputation: 235

Executing Workflow(s) in parallel

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?

Upvotes: 0

Views: 837

Answers (1)

Strillo
Strillo

Reputation: 2982

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.

Upvotes: 1

Related Questions