private void DialogBoxFormClosing(object sender, FormClosingEventArgs e)
{
//When there is a "fatal exception", we terminate the gui toolkit, which calls Application.Exit().
//So, we can't cancel the close, otherwise the application can get into a funny state.
if (e.CloseReason == System.Windows.Forms.CloseReason.ApplicationExitCall || _reallyClose)
return;
e.Cancel = true;
// raise the close requested event
// if this results in an actual close, the Dispose method will be called, setting the _reallyClose flag
RaiseCloseRequested();
}
}