title: How to limit the Process's CPU usage on Windows?
body: <p>I need to control my application's CPU usage to a certain limit. My application will run on Win XP, Vista, Win7 and Windows 8.</p>
  
  <p>I tried implementing to get the current process's CPU usage and using the Sleep() method.(I used  the APIs GetProcessTimes&amp; GetSystemTimes)</p>
  
  <p>pseudo code:</p>
  
  <pre><code>    for(;;)
      {
           //Get the current process's CPU Usage
           int cpuUsage  = CalculateCPUUsage();
           if(cpuUsage &gt; 50)
               Sleep(10)
           else
          {
             //Project implementation code
          }    
      }
  </code></pre>
  
  <p><strong>Question:</strong></p>
  
  <p>Can I write an application to monitor a process's CPU Usage and whenever the CPU reaches the allowed limit, stop the process and continue it.</p>
  
  <p>Thanks in advance for your help.</p>