Do you provide a warning before the program exits?

Last updated by Brady Stroud [SSW] about 2 months ago.See history

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

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.

We open source. Powered by GitHub