skaeff
skaeff

Reputation: 753

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.

Upvotes: 0

Views: 2551

Answers (2)

skaeff
skaeff

Reputation: 753

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.

Upvotes: 0

user437631
user437631

Reputation: 1112

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

Win32_PerfFormattedData_PerfProc_Process is your class for getting CPU data.

Upvotes: 1

Related Questions