关于 Environment.ProcessorCount 的问题 [英] Question about Environment.ProcessorCount

查看:38
本文介绍了关于 Environment.ProcessorCount 的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇 .NET 属性 Environment.ProcessorCount 实际返回的内容.它是否返回内核数量、处理器数量或两者?如果我的计算机有 2 个处理器,每个处理器有 4 个内核,Environment.ProcessorCount 会返回 2、4 还是 8?

I am curious as to what the .NET property Environment.ProcessorCount actually returns. Does it return the number of cores, the number of processors or both? If my computer had 2 processors, each with 4 cores, would Environment.ProcessorCount return 2, 4, or 8?

推荐答案

它将返回 NUMBER_OF_PROCESSORS 环境变量.(请参阅 MSDN)

It will return the NUMBER_OF_PROCESSORS environment variable. (see MSDN)

这将等于逻辑内核的数量 - 即如果您有一个启用 HT 的单核处理器,它将返回 2.

This will equal the number of logical cores - i.e. if you have a HT enabled single core processor, it will return 2.

在你的情况下,它应该返回 8.

In your case, it should return 8.

它将与您将在任务管理器中看到的 CPU 利用率图表的数量相同.

It will be the same number as the number of CPU utilization graphs you will see in task manager.

这篇关于关于 Environment.ProcessorCount 的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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