pistacchio
pistacchio

Reputation: 58863

Measure a process CPU and RAM usage

I've found various ways to track down CPU's and RAM's usage from within a process, in C#. I'd like to obtain those infos for an external program (like providing its PID).

Is there anything in the .NET framework that can help me?

Thanks

Upvotes: 0

Views: 17455

Answers (4)

Tinku
Tinku

Reputation: 1608

you can use process class

Upvotes: 3

Matt Breckon
Matt Breckon

Reputation: 3374

You can pass an instance into a System.Diagnostics.PerformanceCounter constructor - this should allow you to specify the process instance you want to monitor

Upvotes: 0

Neil Barnwell
Neil Barnwell

Reputation: 42095

Use Performance Monitor, and add counters for specific processes.

If you need to analyse the results, you can have them written to a performance log.

Upvotes: 1

Ruben Bartelink
Ruben Bartelink

Reputation: 61795

You could host a PowerShell RunSpace and call stuff in there - it's got a lot more native stuff dealing with this type of thing.

Upvotes: 0

Related Questions