title: How to determine if a previous instance of my application is running?
body: <p>I have a console application in C# in which I run various arcane automation tasks. I am well aware that this should really be a <strong>Windows Service</strong> since it needs to run continuously, but I <strong>don't</strong> want to do that at this time. (So, don't suggest that as an answer).</p>
  
  <p>In the meantime, I need some sample C# code that will allow me to determine if there's already an instance of the Application running. </p>
  
  <p>In the old VB6.0 days, I would have used <code>App.PrevInstance()</code></p>
  
  <p>I want to be able to do this in my Main method:</p>
  
  <pre><code>static void Main()
  {
    if(!MyApp.IsAlreadyRunning())
    {
      while(true)
      {
        RockAndRollAllNightAndPartyEveryDay();
      }
    }
  }
  </code></pre>