[2005] Hide Slow Form Start
I'm connecting to a database and creating a dataset during the Form load event. When I start the application it appears that nothing is happening for about 30 seconds then the form appears. This is due to creation of the dataset. I moved the database connection and dataset fill into the form shown event. This allows the user to see the form immediately but none of the controls are painted until after the database stuff is complete.
I've tried using a thread but because of my limited knowledge of OOP I'm getting lost. I need to use data from textboxes to create my connection string. If I place the database stuff in a thread and try to access any object on my form, I get an error that I can't access the data without explicitly creating an instance of the class.
I tried this and it eliminated the error but, of course, the data that was loaded during the load event was available. i.e text boxes were empty and radio buttons were not selected.
vb Code:
Dim frm as New myForm
frm = myForm
Re: [2005] Hide Slow Form Start
Thanks for the the responses. I decided to use the background worker because I need to use it for another issue on the same UI as well.
It was pretty painless to implement and seems to do what I want. The database is only associated to one button on the form so I simply disable this button until the DB is loaded. The user can utilize the rest of the UI while the DB is loaded.