title: How to check if process is still running before calling Process.GetProcessById?
body: <p>In .NET <a href="http://msdn.microsoft.com/en-us/library/76fkb36k.aspx" rel="noreferrer"><code>Process.GetProcessById</code></a> throws an exception if the process with this ID is not running. How to safely call this method so that it won't throw an exception? I am thinking something like</p>
  
  <pre><code>if(Process.IsRunning(id)) return Process.GetProcessById(id);
  else return null; //or do something else
  </code></pre>
  
  <p>But can't find any method to check the ID, other than probably getting all the running processes and check whether the id exist in the list.</p>