title: Message box with “Yes”, “No” choices in C#?
body: <p>I want to make a MessageBox confirmation. Here is the message box:</p>
  
  <pre><code>DialogResult dialog = MessageBox.Show("Etes vous sûre de vouloir fermer le programme ?", "Exit",MessageBoxButtons.YesNo);
  if (dialog == DialogResult.Yes)
  {
    Application.Exit();
  }
  else if (dialog == DialogResult.No)
  {
      e.Cancel = true;
  }
  </code></pre>
  
  <p>The problem is, when I click the YES Button, the popup does not close automatically. It will be closed after I click 2 times again.
  It should be closed from the first time.</p>
  
  <p>It seems pretty easy but I'm not sure where is my mistake;</p>