I am creating a program that will multiple background tasks simultaneously. I would like to create a number 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.
Asked
Active
Viewed 504 times
1
-
possible duplicate of [How to find the Number of CPU Cores via .NET/C#?](http://stackoverflow.com/questions/1542213/how-to-find-the-number-of-cpu-cores-via-net-c) – cdhowie Jan 07 '11 at 03:48
1 Answers
3
You could use Environment.ProcessorCount
, although I would avoid this sort of optimization because the Task Parallel Library takes care of it for you.

Greg Sansom
- 20,442
- 6
- 58
- 76