title: C# Console App Exit Code with Task Scheduler
body: <p>I have a C# Console application that runs under Windows Task Scheduler.</p>
  
  <p>Should the application fail for what ever reason, I use "Exit Codes" to propagate back to Task Scheduler.</p>
  
  <p>However, no matter what I try, Task Schedule logs always report "Task Completed Successfully".</p>
  
  <p>I have tried the two defined exit strategies.. being...</p>
  
  <pre><code>Environment.Exit(hasError ? -1 : 0);
  </code></pre>
  
  <p>and</p>
  
  <pre><code>static int Main(string[] args)
  {
      ... code ...
     return (hasError ? -1 : 0);
  }
  </code></pre>
  
  <p>Any suggestions what I may be doing wrong</p>
  
  <p>Running app in Windows Server 2012 Standard</p>