开发者

Multithreading in Workflow 4.0

I 开发者_如何学JAVAwant 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?


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.


To achieve parallel execution of a foreach, use ParallelForEach.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜