Multithreading in Workflow 4.0

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

+4
source share
2 answers

It depends on what kind of work you are doing. By default, a workflow scheduler will only perform one action in a workflow at a time, by no means bypassing this. Concurrent actions plan multiple child actions at the same time, but they are not executed in parallel.

The big exception to this rule is actions of the AsyncCodeActivity type. The scheduler will perform another action as soon as they do asynchronous material. Now this works best with binding IO to work, such as database access or network I / O, but this is not a requirement.

To achieve true parallelism in your workflows, you need to use a combination of one of the parallel actions with actions that come from AsyncCodeActivity.

+6
source

To ensure parallel execution of foreach, use ParallelForEach .

-1
source

All Articles