title: PerformanceCounter CPU & Memory like Task Manager
body: <p>I am trying to monitor both CPU and Memory and get matching values (or as close as possible) to TaskManager values. So far I have:</p>
  
  <pre><code>static readonly PerformanceCounter IdleCounter = new PerformanceCounter("Processor", "% Idle Time", "_Total");
  static readonly PerformanceCounter RamCounter = new PerformanceCounter("Memory", "Available MBytes");
  
  public string f() {
    return "cpu: " + (100-IdleCounter.NextValue()) + " , ram: " + RamCounter.NextValue() + "MB";
  }
  </code></pre>
  
  <p>This give pretty accurate (as inc comparison to TaskManager) value for cpu, though I would like to get even closer if possible.
  <br><br>
  For memory however it doesn't seem to match, I get a number but what I really want is a percent like Task Manager shows ..</p>
  
  <p>Any help ?</p>