开发者

How to get cpu usage % in C# for each running process

开发者 https://www.devze.com 2023-01-24 22:01 出处:网络
I use System.Diagnostics.Process.GetProcesses() to get process list. I found TotalProcessorTime property for each process - it is TimeSpan.

I use System.Diagnostics.Process.GetProcesses() to get process list. I found TotalProcessorTime property for each process - it is TimeSpan.

But how to get relative values of CPU usage, i. e. i need 开发者_开发技巧% of total CPU usage for each running process.


use WQL (queries WMI like SQL) see attached link for few samples:WQL

Win32_PerfFormattedData_PerfProc_Process is your class for getting CPU data.


I found a workaround decision see this question

The plan is as follows: take counters data in stndard way, then process log files. Realtime monitoring is not critical.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号