Can a C# program measure its own CPU usage somehow?

后端 未结 5 961
名媛妹妹
名媛妹妹 2020-12-12 18:54

I am working on a background program that will be running for a long time, and I have a external logging program (SmartInspect) that I want to feed with some values periodic

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-12 19:21

    Have a look at System.Diagnostics.PerformanceCounter. If you run up perfmon.exe, you'll see the range of performance counters available to you (set the 'performance object' to 'Process'), one of which is '% Processor Time'.

提交回复
热议问题