strategy to get around slow application startup...

as long as I dropped controls onto the form designer, the application starts up pronto. Imperceptible flicker/painting as the form loads up with tab controls, toolstrips, text boxes, etc.

InitializeComponent within Mainform.designer.vb works.

The problem is when I add usercontrols in Form_Load. The startup performance degrades noticeably and precipitously with a dozen controls.

OK, I am not in Oz or statically linked exe's anymore...the code compiles on the fly.

As an experiment I thought I would move the ResumeLayouts/ PerformLayout to the end of the form_load instead of at the end of InitializeComponent. That helped somewhat but it threw into a tizzy some SplitterContainer splitterdistance preperty settings. It's getting complicated now.

Proposition Launch a splashcreen prior to InitializeComponent. Put an event/method in the splashscreen form which will be called as the last line of form_load. So far, my attempts to use the splashscreen have resulted in a Splashscreen which seems to only show up during InitializeComponent, but then exits stage right when I really need it, right at the point when the GUI begins its Art Deco repaint performance, which is interesting the first time, but gets old really fast. 3-4 seconds of agonizing rearrangement of furniture and props on the stage without the curtain closed.

My question here is, do I have to do this on a separate thread How do I tell the Mainform to chill while the splashscreen hides the machinations going on between the CPU, Memory and the Graphics card

All my attempts to make set Mainform visibility to false(or set the location to somewhere off the view) before it is ready to display its already completed form have not worked.

Anyone appreciatively, -greg



Answer this question

strategy to get around slow application startup...

  • magicalclick

    Set startup to Sub Main():

    Public Sub Main(ByVal Args() As String)

    Dim Splash As New frmSplash

    Dim MainForm As Form1

    Splash.Show()

    MainForm = New Form1

    Splash.Close()

    Application.Run(MainForm)

    End Sub

    'In Form1

    Public Sub New()

    MyBase.New()

    'This call is required by the Windows Form Designer.

    InitializeComponent()

    'Add any initialization after the InitializeComponent() call

    'Long time to do stuff....

    System.Threading.Thread.CurrentThread.Sleep(5000)

    End Sub


  • Chelion

    As a workaround you can set the splashform as your startup and then call the initialization code of the "Main" form...when that code is done executing Hide the splashform from the user and then show the main form....

  • Mystagogue

    hazz wrote:
    4. Mainform. ' now I have to pass execution on to the Mainform since the Startup form was the splashscreen. How would that go

    SplashScreen

    Dim f as new MainForm

    F.InitSub

    F.Show (anything in the load event will be processed here)

    me.hide



  • lmttag

    Set startup to Sub Main():

    Public Sub Main(ByVal Args() As String)

    Dim Splash As New frmSplash

    Dim MainForm As Form1

    Splash.Show()

    MainForm = New Form1

    Splash.Close()

    Application.Run(MainForm)

    End Sub

    'In Form1

    Public Sub New()

    MyBase.New()

    'This call is required by the Windows Form Designer.

    InitializeComponent()

    'Add any initialization after the InitializeComponent() call

    'Long time to do stuff....

    System.Threading.Thread.CurrentThread.Sleep(5000)

    End Sub


  • Jinz

    hmm. Set Startup form:   SplashScreenForm

      and what pops up just before the SplashScreen....the Mainform....who I would just like to chill until it's time for the big boy to make his appearance.

     

    I don't see anything in the Mainform's code which would cause it to ignore the application framework instruction for it NOT to be the startup form....and pre-emptively take matters into its own hands... 

    ok...I blew away some existing code in applicationEvents.vb and created a new Splashscreen, the one provided by the .NET and the splashscreen comes up and that's all.  A start!!


  • Tom Janssen

    You DMan....again.

    I really was expecting a simple answer..and that is a simple answer.

    But I would need to call the Mainform_load event from the splashscreen in addition to calling Mainform's initializeComponent.   Then after that sequential process hide the splashscreen and make Mainform visible.

    Splashscreen

         1.. Mainform.InitializeComponent.

          2.  Mainform_Load

          3.  Me.Hide

          4. Mainform.  ' now I have to pass execution on to the Mainform since the Startup form was the splashscreen. How would that go

    I'll try that and look at this idea which is a bit more complex but looks to address the issue.  -greg

    http://www.codeproject.com/useritems/usesplashscreen.asp


  • titote

    As a workaround you can set the splashform as your startup and then call the initialization code of the "Main" form...when that code is done executing Hide the splashform from the user and then show the main form....

  • GaryPod

    hmm. Set Startup form:   SplashScreenForm

      and what pops up just before the SplashScreen....the Mainform....who I would just like to chill until it's time for the big boy to make his appearance.

     

    I don't see anything in the Mainform's code which would cause it to ignore the application framework instruction for it NOT to be the startup form....and pre-emptively take matters into its own hands... 

    ok...I blew away some existing code in applicationEvents.vb and created a new Splashscreen, the one provided by the .NET and the splashscreen comes up and that's all.  A start!!


  • Bor

    You DMan....again.

    I really was expecting a simple answer..and that is a simple answer.

    But I would need to call the Mainform_load event from the splashscreen in addition to calling Mainform's initializeComponent.   Then after that sequential process hide the splashscreen and make Mainform visible.

    Splashscreen

         1.. Mainform.InitializeComponent.

          2.  Mainform_Load

          3.  Me.Hide

          4. Mainform.  ' now I have to pass execution on to the Mainform since the Startup form was the splashscreen. How would that go

    I'll try that and look at this idea which is a bit more complex but looks to address the issue.  -greg

    http://www.codeproject.com/useritems/usesplashscreen.asp


  • hashbrown

    hazz wrote:
    4. Mainform. ' now I have to pass execution on to the Mainform since the Startup form was the splashscreen. How would that go

    SplashScreen

    Dim f as new MainForm

    F.InitSub

    F.Show (anything in the load event will be processed here)

    me.hide



  • strategy to get around slow application startup...