我可以配置用于并行扩展的线程数? [英] Can I configure the number of threads used by Parallel Extensions?

查看:151
本文介绍了我可以配置用于并行扩展的线程数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用的并行扩展是无扩展的。净(RX)。我相信他们也可以通过.NET 4.0 Beta版本。

I'm currently using the Parallel Extensions that are part of Reactive Extensions for .Net(Rx). I believe they are also available through .Net 4 beta releases.

1)有没有什么办法来确定多少线程实际上被利用。我认为这是关系到 Environment.ProcessorCount (#逻辑核心),但我想检查一下。

1) Is there any way to determine how many threads are actually being utilized. I assume this is related to Environment.ProcessorCount (# of logical cores) but I want to check this.

2)有什么办法配置你希望有多少线程使用的?我注意到有一个 ParallelOptions.MaxDegreeOfParallelism 属性,它看起来很有希望,但它似乎默认为-1(没有限制的线程数),我也不太清楚这是否可以设置一次为当前应用程序,而不是被传递到每个调用的Parallel.For()等。

2) Is there any way of configuring how many thread you wish to use? I noticed there is a ParallelOptions.MaxDegreeOfParallelism property that looks promising but it appears to default to -1 (no limit to the number of threads) and I'm also not quite sure if this can be set once for the current application, as opposed to being passed in to each call to Parallel.For(), etc.

推荐答案

更​​新:此选项出现在.NET 4中; ParallelOptions.MaxDegreeOfParallelism

UPDATE: This option appeared in .Net 4; ParallelOptions.MaxDegreeOfParallelism

在回答我的问题,答案似乎仅仅是 - 号使用不会出现线程/核心的数量是可配置的

In answer to my own question, the answer appears to simply be - No. The number of threads/cores used doesn't appear to be configurable.

这篇关于我可以配置用于并行扩展的线程数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆