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?
Asked
Active
Viewed 588 times
0
-
The answer to this question is given here: http://stackoverflow.com/questions/8856224/execute-single-workflow-instance-in-parallel – Yuriy Magurdumov Jan 17 '12 at 14:33
-
1I mean you need to look through the questions you have asked in the past and if an answer helped you then award it. This will encourage others to help you in the future. – tom redfern Sep 06 '12 at 08:43
1 Answers
1
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.

Strillo
- 2,952
- 13
- 15
-
What I meant by expensive is that my workflow consists of hundreds of activities that are declared in XAML. Instantiating a workflow means running constructors for each activity in it, right? Besides, they need to be garbage collected at some point. So imagine what happens if hundreds of objects are instantiated for every single request!? Isn't it a waste of resources? – Yuriy Magurdumov Dec 14 '11 at 14:29