c pound

I reject your reality and substitute my own!
posts - 46, comments - 37, trackbacks - 40

My Links

News

Archives

Image Galleries

Blog Communities

Blog is a stupid word

Lunch Hour

Resources

The way things are done

So, what if you need to pop up a dialog box that could potentially abort the application before you pop up your main form? There are usually no good reasons to construct objects that you don't intend to use. That would include opening a Form which will immediately be closed. But is the following acceptable? I know it's possible... I'm doing it. But what could go wrong in this situation? This must be bad in some way that I haven't found yet.

[STAThread]
static void Main()
{
    //let the user choose a database before we start the program
    DialogResult dr = frmDatabases.Instance.ShowDialog();

    if
(dr == DialogResult.OK)
        Application.Run(
new frmMain());
}

Print | posted on Thursday, January 05, 2006 6:43 AM |

Feedback

Gravatar

# re: The way things are done

You need not worry about aborting the application before opening the main form using the Run method.

Executing code before calling Run is what you'd be doing if you needed to prevent multiple instances of an application from running, for example.

An example of a useful dialog at startup may be to retrieve some setup information from the user that is required by the main form before a user configuration file is created.
1/6/2006 7:00 PM | Anthony Trudeau
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 

Powered by: