Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detecting number of CPUs

Status
Not open for further replies.

Clairvoyant1332

Programmer
May 21, 2003
147
US
I've searched through the VB.NET documentation, but couldn't find any way of detecting the number of CPUs (logical or physical) on a system. Anyone know how to do this?

Dennis
 
Some interesting reading on thread classes, but it doesn't mention anything about processors. I've alredy written a program using the Thread class, but I currently hardcode the number of threads I'm using, and would prefer to optimize that number based on available hardware.
 
Hi,

This should work on windows NT and higher (It works on my xp machine anyway):
-----------------------------------------------
MessageBox.Show(System.Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS"))
-----------------------------------------------

Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top