title: How to determine if a process ID exists
body: <p>I'm using C# .NET 2.0.  I need to determine if a PID exists.  I came up with the following code:</p>
  
  <pre><code>private bool ProcessExists(int iProcessID)
  {
      foreach (Process p in Process.GetProcesses())
      {
          if (p.Id == iProcessID)
          {
              return true;
          }
      }
      return false;
  }
  </code></pre>
  
  <p>Is there a better way to do this other than iterating all the processes?</p>