title: Windows 8/10 API Detect suspended process
body: <p>UWP (or "Metro") apps in Windows 8/10 are frequently suspended when they are not in the foreground. Apps in this state continue to exist but no longer consume CPU time. This change seems to have been introduced to improve performance on low-power/storage devices like tablets and phones.</p>
  
  <p>Please can I ask, what is the most elegant and simple method to detect an app in this state?</p>
  
  <p>I can see 2 possible solutions at the moment:</p>
  
  <ol>
  <li><p>Call NtQuerySystemInformation() and the enumerate each process and each thread. A process is "suspended" if all threads are in the suspended state. This approach will require a lot of code and critically NtQuerySystemInformation() is only semi-documented and could be removed in a future OS. NtQueryInformationProcess() may also offer a solution with the same problem.</p></li>
  <li><p>Call GetProcessTimes() and record the counters for each process. Wait some time (minutes) and check these again. If the process counters haven't changed then assume the process is suspended. This is a hack and I may get shot down for even thinking of it.</p></li>
  </ol>
  
  <p>Jim </p>