title: Application Close on DialogResult
body: <p>I have a C# GUI application. When the user clicks on the red 'X' (for closing the app) I want to show a message and ask if he really wants to close it.</p>
  
  <p>I found a solution:</p>
  
  <pre><code>        DialogResult dialog = MessageBox.Show("Do you really want to close the program?", "SomeTitle", MessageBoxButtons.YesNo);
          if (dialog == DialogResult.Yes)
          {
              Application.Exit();
          }else if (dialog == DialogResult.No)
          {
            //don't do anything
          }
  </code></pre>
  
  <p>When the user clicks 'yes', the application should terminate completely. (Is Application.Exit() correct for this purpose?)</p>
  
  <p>When the user clicks 'no', the DialogResult/MessageBox should close, but the application should stay opened. However, it closes!!</p>
  
  <p>How can I avoid this?  </p>
  
  <p>BTW: I use Visual Studio 2010 and Winforms.</p>