Franz Payer
Franz Payer

Reputation: 4137

detect how many cores a client has using C#

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.

Upvotes: 1

Views: 509

Answers (1)

Greg Sansom
Greg Sansom

Reputation: 20870

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

Upvotes: 3

Related Questions