0

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

pistacchio
  • 56,889
  • 107
  • 278
  • 420
  • you mean, like passing a PID as argument? – jasonco Nov 18 '09 at 09:16
  • check this http://stackoverflow.com/questions/278071/how-to-get-the-cpu-usage-c You can also use WMI( windows management instrumentation) for memeory usage . Check Win32_process class http://msdn.microsoft.com/en-us/library/aa394372(VS.85).aspx Also you can go for performance counters (you code require admin privileges ) Look into WMI. – PRR Nov 18 '09 at 09:51

4 Answers4

3

you can use process class

Tinku
  • 1,592
  • 1
  • 15
  • 27
1

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
  • 41,080
  • 29
  • 148
  • 220
0

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
  • 59,778
  • 26
  • 187
  • 249
0

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,374
  • 20
  • 26