Multiple Processors and PerformanceCounter C#

后端 未结 2 400
清酒与你
清酒与你 2020-12-19 10:20

I\'m trying to figure out how to gather the current usage percentage of each individual processor on my computer. If I use \"System.Environment.ProcessorCount;\" I can get

相关标签:
2条回答
  • 2020-12-19 10:49

    Since I left my original question I happened to find the Windows Performance Monitor (C:\Windows\system32\perfmon.msc) on my Windows 7 computer. If one right-clicks the graph on the main window and chooses "Add Counters" then a list of possible strings to use as parameters in the PerformanceCounter is displayed for just about everything one would want to monitor.

    0 讨论(0)
  • 2020-12-19 11:12

    For the first processor, use

    protected PerformanceCounter cpuCounter = 
      new PerformanceCounter("processor", "% Processor Time", "0");
    

    And so on, up to (Environment.ProcessorCount-1).ToString()

    0 讨论(0)
提交回复
热议问题