Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Form is loading very hard, and I need a loader :(

Form is loading very hard, and I need a loader :(

Scheduled Pinned Locked Moved .NET (Core and Framework)
tutorialhelp
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sodevrom
    wrote on last edited by
    #1

    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

    D L 2 Replies Last reply
    0
    • S sodevrom

      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

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      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

      L 1 Reply Last reply
      0
      • S sodevrom

        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

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        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 :)

        1 Reply Last reply
        0
        • D Dave Kreskowiak

          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

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Dave 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


          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups