Search code examples
c#processsystem.diagnosticsprocesslist

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


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.


Solution

  • 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.