如何提高并发并行任务,System.Threading.Parallel(.NET 4.0) [英] How to increase concurrent parallel tasks with System.Threading.Parallel (.Net 4.0)
问题描述
我尝试用新的System.Threading.Parallel方法,如并行和foreach。
他们似乎很好地工作,但我需要一种方法来增加被执行的这8个(我有一个四核心)的并发线程数。
我知道有一种方法,我只是能找到的地方你所隐藏的那该死的属性。
吉拉德。
报价:
VAR的查询=从项目中source.AsParallel()。WithDegreeOfParallelism(10)
其中,计算(项目)> 42
选择项目;
在其中一个查询正在执行显著量的非受计算量限制的工作,如文件的情况下的I / O,这可能是有益的,以指定并行度大于机床上的核心数量的对>
来自: MSDN
I'm experimenting with the new System.Threading.Parallel methods like parallel for and foreach.
They seem to work nicely but I need a way to increase the number of concurrent threads that are executed which are 8 (I have a Quad core).
I know there is a way I just can find the place thy hidden the damn property.
Gilad.
quote:
var query = from item in source.AsParallel().WithDegreeOfParallelism(10)
where Compute(item) > 42
select item;
In cases where a query is performing a significant amount of non-compute-bound work such as File I/O, it might be beneficial to specify a degree of parallelism greater than the number of cores on the machine.
from: MSDN
这篇关于如何提高并发并行任务,System.Threading.Parallel(.NET 4.0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!