0

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.

skaeff
  • 753
  • 2
  • 13
  • 25
  • Possible duplicate: http://stackoverflow.com/questions/278071/how-to-get-the-cpu-usage-in-c – digEmAll Nov 10 '10 at 09:55
  • 1
    Also read Hans' answer to understand what CPU percentage actually means: http://stackoverflow.com/questions/4134199/processor-usage/4135301#4135301 – Dirk Vollmar Nov 10 '10 at 10:14

2 Answers2

1

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

Win32_PerfFormattedData_PerfProc_Process is your class for getting CPU data.

user437631
  • 1,112
  • 4
  • 12
  • 28
0

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.

Community
  • 1
  • 1
skaeff
  • 753
  • 2
  • 13
  • 25