title: Start a C# windows application and wait for exiting in command line
body: <p>Usually, calling windows application in command prompt does not wait its exit. Once I type <code>myFormApp.exe</code> and press enter, a form will display and command prompt moves to next line immediately.</p>
  
  <pre><code>C:\&gt; myFormApp.exe
  C:\&gt;     # this line will display immediately
  </code></pre>
  
  <p>I know using <code>cmd /c</code> will wait for application exit.</p>
  
  <pre><code>C:\&gt; cmd /c myFormApp.exe
  C:\&gt;     # this line will display after myFormApp.exe closed
  </code></pre>
  
  <p>But I want to waiting even in lack of <code>cmd /c</code>.</p>
  
  <p>Is there any way to prevent command prompt to move to new line, with editing myFormApp.exe source code?</p>
  
  <p>Adding <code>AllocConsole</code> to windows application will show console, but it does not make command prompt to wait exiting.</p>
  
  <pre><code>if (args.Length &gt; 0)
  {
      // Command line given, display console
      AllocConsole();
  }
  else
  {
      Application.EnableVisualStyles();
      Application.SetCompatibleTextRenderingDefault(false);
      Application.Run(new Form1());
  }
  </code></pre>
  
  <p>Any advices will be appreciated. Thanks!</p>