Detecting the number of processors

后端 未结 8 1626
耶瑟儿~
耶瑟儿~ 2020-11-30 10:50

How do you detect the number of physical processors/cores in .net?

8条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-30 11:39

    This actually varies quite a bit depending on the target platform. Stephbu's answer will work great on XP SP3 and newer.

    If you are targeting older platforms, you may want to check out this article. I wrote it about half a year ago and in it I discuss several different ways to do this as well as the individual pros and cons of each method.

    You may also want to check out this code project article if you are interested in differentiating shadow cores from hyperthreading from real ones.

提交回复
热议问题