Do you provide a warning before the program exits?

Loading last updated info...

A product should not close without providing a warning. We use the following message box to warn the user before closing a program:

Image

✅ Figure: Good Example - Standard warning before a program exits

private void OnExit(object sender)
{
EventHandler handler = ExitRequest;
if (handler!= null )
{
handler(sender, EventArgs.Empty);
return;
}
string closeTitle = string.Format("Exiting{0}", Application.ProductName);
string closeMessage = string.Format("Are you sure you want to exit {0}", Application.ProductName);
DialogResult result = MessageBox.Show(closeMessage, closeTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (result == DialogResult.Yes)
{
Application.Exit();
}
}

We have an example of this in the SSW .NET Toolkit.

Need help?

SSW Consulting has over 30 years of experience developing awesome software solutions.

We open source.Loving SSW Rules? Star us on GitHub. Star