I have the following code snippet to close my application.
private void frmAgent_FormClosing(object sender, FormClosingEventArgs e)
{
if (MessageBox.Show("Deseja realmente fechar o sistema?", "Atenção!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
Application.Exit();
}
else
{
e.Cancel = true;
}
But when I click to close and click on sim
it falls into if
, it executes the Application.Exit();
excerpt and returns to the start of the method by opening MessageBox
again. If I click on sim
again, then it will close form
. Has anyone seen this?