In the Load event or in the constructor after the InitializeComponent()?
or doesn’t matter at all?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The Form.Shown event is a good place to do any initialization that may take more than about one second. Form.Shown occurs once only, just after the form is first made visible to the user.
Obviously if you have a lengthy initialization you still need to provide some sort of visual feedback and perhaps disable sections of the form until complete. But if the initialization is unavoidable, Form.Shown at least allows you to let the user know the application has not frozen and give feedback on what it is actually doing.
Compared to Form.Load: From the users perspective your application will be perceived to start up more quickly because your Form is already visible while initialization is done.
Compared to Form.Activated: You don’t need to worry about your initialization running multiple times because the Activated event is called every time your form is hidden/shown, minimized/maximized etc.
Compared to the constructor: Similar to Form.Load your form will not be visible until initialization is complete. Also, you must be more careful about timing/sequence issues related to controls that may not be fully initialized.