开发者

detect how many cores a client has using C#

开发者 https://www.devze.com 2023-02-03 04:07 出处:网络
I am creating a program that will multiple background tasks simultaneously. I would like to create a numbe开发者_开发问答r of threads to do these based on the number of cores that a client is running.

I am creating a program that will multiple background tasks simultaneously. I would like to create a numbe开发者_开发问答r of threads to do these based on the number of cores that a client is running. So that if they are using a multi-core processor, the program will run faster. Is there any way to have C# check how many cores a processor has? Finding model of the processor would also work.


You could use Environment.ProcessorCount, although I would avoid this sort of optimization because the Task Parallel Library takes care of it for you.

0

精彩评论

暂无评论...
验证码 换一张
取 消