Multiple Processors and PerformanceCounter C#

后端 未结 2 401
清酒与你
清酒与你 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 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()

提交回复
热议问题