I use following c# code to get processor information. The Management class is null if I run my application on a virtual machine. I use Oracle VM VirtualBox as my virtual pc (Windows XP SP3)
System.Management.ManagementClass Management = new System.Management.ManagementClass("Win32_Processor");
Does anyone has experience about using such code and has problems in virtual machines.
To calculate the number of logical CPUs in vSphere Client, multiply the number of sockets by the number of cores. For example, if you need to configure a VM to use 2-processor sockets, each has 2 CPU cores, then the total number of logical CPUs is 2*2=4.
CPU virtualization emphasizes performance and runs directly on the processor whenever possible. The underlying physical resources are used whenever possible and the virtualization layer runs instructions only as needed to make virtual machines operate as if they were running directly on a physical machine.
Oracle VirtualBox does not provide such information.
Here is the related ticket.
https://www.virtualbox.org/ticket/9046
Are you using GetInstances
?
System.Management.ManagementClass ManagementClass1 = new System.Management.ManagementClass("Win32_Processor"); System.Management.ManagementObjectCollection ManagementObjectCollection1 = ManagementClass1.GetInstances(); foreach (System.Management.ManagementObject managementobject in ManagementObjectCollection1) { Console.Out.WriteLine(managementobject.Properties["Name"].Value); } Console.In.ReadLine();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With