views:

297

answers:

4

Hi, 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

+1  A: 

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.

Neil Barnwell
I need this for logging purposes, so I need to get the data in a format i can write, store and analyze.
pistacchio
You can save to a performance log from performance monitor: http://technet.microsoft.com/en-us/library/cc721865.aspx
Neil Barnwell
A: 

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.

Ruben Bartelink
A: 

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

Matt Breckon
+3  A: 

you can use process class

Tinku
Memory usage is a bit tricky as it means various things
Tinku