title: What is the best way to keep a C# Console app running
body: <p>I have developed a console app which must run in the background.  The app must constantly check a database for new records.  If new records are returned they are processed.  My app as it currently stands uses while(true) to keep the application running.  Is using a while loop the best solution.</p>
  
  <p>A snippet of my code:</p>
  
  <pre><code>static void Main(string[] args)
  {
    while(true)
    {
      // Query db for new records
      if(record_count &gt; 0)
      {
        // Process the records
      }
      Thread.Sleep(500);
    }
  }
  </code></pre>