如何使用System.Threading.Parallel(.Net 4.0)增加并发并行任务(How to increase concurrent parallel tasks with Syste

编程入门 行业动态 更新时间:2024-10-26 19:34:51
如何使用System.Threading.Parallel(.Net 4.0)增加并发并行任务(How to increase concurrent parallel tasks with System.Threading.Parallel (.Net 4.0))

我正在尝试新的System.Threading.Parallel方法,如parallel和foreach。

他们似乎很好地工作,但我需要一种方法来增加执行的并发线程数为8(我有一个四核心)。

我知道有一种方法我可以找到你隐藏该死的财产的地方。

吉拉德。

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.

最满意答案

引用:

var query = from item in source.AsParallel().WithDegreeOfParallelism(10) where Compute(item) > 42 select item;

在查询执行大量非计算限制工作(如文件I / O)的情况下,指定比机器上的内核数量多的并行度可能会有所帮助。

来自: MSDN

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

更多推荐

本文发布于:2023-07-26 19:27:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1279944.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   Threading   Parallel   Net   System

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!