title: Exit from a console application in C#
body: <p>I read a lot of things here on stackoverflow, comments, opinions and every kind of ideas. But anyway, I really need an explained way to exit my console application (I'm on VS2010 Framework 4) on C# with a custom error.</p>
  
  <p>The best thing I could read right now is on VB:</p>
  
  <pre><code>Private Declare Sub ExitProcess Lib "kernel32" (ByVal uExitCode As Long)
  </code></pre>
  
  <p>and use ExitProcess(1) for an error or ExitProcess(0)</p>
  
  <p>So my questions are:</p>
  
  <ul>
  <li>Is the same than Environment.Exit(1) ?</li>
  <li>What is the better for an application that runs as automatic job?</li>
  <li>What means the exit codes, -1, 0, 1, and what are their differences? </li>
  <li>What about static void ExitProcess(uint uExitCode); ?</li>
  </ul>
  
  <p>Some previously questions marked as bibliography:</p>
  
  <p><a href="https://stackoverflow.com/questions/10286056/c-sharp-what-the-command-for-exit-console-application">What is the command to exit a Console application in C#?</a></p>
  
  <p><a href="http://geekswithblogs.net/mtreadwell/archive/2004/06/06/6123.aspx" rel="nofollow noreferrer">http://geekswithblogs.net/mtreadwell/archive/2004/06/06/6123.aspx</a></p>