title: exit application error
body: <p>I developed a simple windows application on .NET 4.
  I'd like to pass a parameter to my application and if this parameter was empty the application should not continue running and quit.</p>
  
  <p>I add an input parameter in the main method. It works fine when I debug it in my Visual Studio but when I execute my application directly Windows gave me this error:</p>
  
  <p>"application has stopped working"</p>
  
  <p>How can i handle it? I tested some codes but it doesn't work</p>
  
  <pre><code> Application.ExitThread();
   Application.Exit();
  </code></pre>
  
  <p>This is may main method:</p>
  
  <pre><code> [STAThread]
   static void Main(string[] args)
   {
       if(args.Count()==0)
        Thread.CurrentThread.Abort(); 
  
          Application.EnableVisualStyles();
          Application.SetCompatibleTextRenderingDefault(false);
  
          Application.Run(new Form1());
   }
  </code></pre>
  
  <p>I looked at Windows  Event Viewer and found this error events</p>
  
  <pre><code>Application: WindowsFormsApplication1.exe
  Framework Version: v4.0.30319
  Description: The process was terminated due to an unhandled exception.
  Exception Info: System.Threading.ThreadAbortException
  Stack:
  at System.Threading.Thread.AbortInternal()
  at System.Threading.Thread.Abort()
  at WindowsFormsApplication1.Program.Main()
  </code></pre>
  
  <p>and another:</p>
  
  <pre><code>Faulting application name: WindowsFormsApplication1.exe, version: 1.0.0.0, time 
  stamp:    0x50e775e3
  Faulting module name: KERNELBASE.dll, version: 6.1.7601.17514, time stamp: 0x4ce7c78c
  Exception code: 0xe0434352
  Fault offset: 0x000000000000a49d
  Faulting process id: 0x15b4
  Faulting application start time: 0x01cdeade1bdab018
  Faulting application path: C:\WindowsFormsApplication1\WindowsFormsApplication1 
   \bin\Debug\WindowsFormsApplication1.exe
  Faulting module path: C:\Windows\system32\KERNELBASE.dll
  Report Id: 5a6d1a1f-56d1-11e2-8ffd-20cf30e7bd24
  </code></pre>