Form is loading very hard, and I need a loader :(
-
Hello, I have a UserControl that contains a tab control that has about 8 pages. Each pages have a lot of controls and all 8 pages need to be loaded at the same time. The UserControl is opened when a user click on a button from the main form. I searched the entire CodeProject for splashscreens or good loaders, but I didn't find anything useful. Can someone guide me on how to load the usercontrol without hanging the application. I don't mind if it takes 10 seconds, but I would like a loader in this time, without freezing the entire application. Hope you can help, Thank you
-
Hello, I have a UserControl that contains a tab control that has about 8 pages. Each pages have a lot of controls and all 8 pages need to be loaded at the same time. The UserControl is opened when a user click on a button from the main form. I searched the entire CodeProject for splashscreens or good loaders, but I didn't find anything useful. Can someone guide me on how to load the usercontrol without hanging the application. I don't mind if it takes 10 seconds, but I would like a loader in this time, without freezing the entire application. Hope you can help, Thank you
The problem you have is it takes so long to load the form because you have sooooo many controls. Reduce the number of controls, such as scrapping the tab page layout and moving them to seperate forms that you only load when you absolutely need to show them (you have 8 tabs remember, you can only see one tab at a time!) You have a second problem. Since all the controls must be created on the UI thread in order to work properly, showing a "Progress Bar" (not "loader") isn't going to work very well, because it also gets drawn on the UI thread, which will be too busy creating your large number of controls, and hence, won't be able to show "progress".
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
Hello, I have a UserControl that contains a tab control that has about 8 pages. Each pages have a lot of controls and all 8 pages need to be loaded at the same time. The UserControl is opened when a user click on a button from the main form. I searched the entire CodeProject for splashscreens or good loaders, but I didn't find anything useful. Can someone guide me on how to load the usercontrol without hanging the application. I don't mind if it takes 10 seconds, but I would like a loader in this time, without freezing the entire application. Hope you can help, Thank you
Try to load your tabpages one at a time; - Divide your 8 pages over 8 usercontrols - Put the drawing of your form on hold - Add an usercontrol-array to the form that can hold those 8 usercontrols - Load them one atta time. (You might use a counter, busy animation etc) - Add the newly created usercontrol to the (controls collection of the) appropriate tabpage Good luck :)
I are troll :)
-
The problem you have is it takes so long to load the form because you have sooooo many controls. Reduce the number of controls, such as scrapping the tab page layout and moving them to seperate forms that you only load when you absolutely need to show them (you have 8 tabs remember, you can only see one tab at a time!) You have a second problem. Since all the controls must be created on the UI thread in order to work properly, showing a "Progress Bar" (not "loader") isn't going to work very well, because it also gets drawn on the UI thread, which will be too busy creating your large number of controls, and hence, won't be able to show "progress".
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008Dave Kreskowiak wrote:
second problem.
The way I handle this seems to work perfectly: - first create the splash form, make it TopMost and show it modelessly; a simple splash appears right away and holds a progress bar, a listbox showing what is going on, and a cancel button. Plus all the aesthetics one might want to add. - then construct the slow form and pass a reference to the splash form to it, so it can add items to the activity listbox, advance the progress, and when loaded close the splash (with a small delay so you still can read the latest listbox updates). I have a SplashWindow class that supports this, and I tend to use a using construct for the splash so it also disappears when something goes wrong during the main forms construction. :)
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets