Splash loader - Why after .dlls load does it show?

Drstein99

Junior Contributor
Joined
Sep 26, 2003
Messages
283
Location
Audubon, Nj
My applicaiton loads .dll's and takes a while to start, initially. I put a splash screen up to alert users, that "loading be patient".


I'm finding that the program loads the .dll's, AND THEN shows the form, which is completely useless. I want the display to appear on program execution click. While loading, display "be patient". After load, then hide, or go away - I don't care. But showing the splash for a second after there is no need to wait since everything else is ready to run is pointless.

Does anyone know how to resolve this, can advise - please? Thanks.
 
I have exacly the same problem (well, I think everyone have this problem).

The delay is due the .NET enterprise plataform being loaded, so, if I put a splash screen, it will only appear after the Enterprise's driver have been fully loaded, making the splash screen useless, like you said... Unless you application is realy big or needs to execute much code at the beggining...

I realy doubt this have a solution... What would be nice would be having Enterprise .NET driver's having a configurable splash screen itself...
 
Last edited:
I was having the same problem. this is how I fixed it. And works for me. Sounds like you need to do the application.doevents right after you have the splash show. That is how I fixed it to work like I wanted.

Private Sub frmATPTESTER_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim frmSplash As New frmPorterSplash
Dim strCommand As String
frmSplash.Show()
Application.DoEvents()
frmSplash.pgbLoad.PerformStep()
Me.xmlread()
' there are many more stuff I have done here but didn't want to list them here.
frmSplash.pgbLoad.PerformStep()
frmSplash.Dispose()
Thread.Sleep(300)
End Sub
 
techmanbd said:
I was having the same problem. this is how I fixed it. And works for me. Sounds like you need to do the application.doevents right after you have the splash show. That is how I fixed it to work like I wanted.

techmanbd buddy, I think you did not understood.

Before the code you wrote can be executed all .NET driver's dlls and stuff must be already resident in memory, that is, you already wait a few seconds until this process finish, with no splash screen, no message, no nothing, only Hard Disk activity...

It's pretty much like having windows starting. You have to wait a bit with your screen black and much disk activity before the first windows message appears saying: "windows is loading", because windows have to load all necessary files to make the screen's message possible to appear. Same thing applys to the .NET plataform...
 
Last edited:
If you start your spalsh screen as the very first thing on the Sub Main, it won't start any dll before...
I'll give you a sample code that must work...
Visual Basic:
Module StartUp
    Public WithEvents SplashForm As New Form1
    Public MainForm As Form2
    Public appContext As ApplicationContext
    Public Sub main()

        appContext = New ApplicationContext(SplashForm)
        Application.Run(appContext)

    End Sub

    Private Sub SplashForm_SplashInitDonne() Handles SplashForm.SplashInitDonne
        'Do anything here before discarding the spash form if you want...
        SplashForm.Hide()
    End Sub
End Module

The following is th Load Event of the Spash form...
Visual Basic:
    Public Event SplashInitDonne()
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'Force the spash form to show
        StartUp.SplashForm.Show()
        Application.DoEvents()

        'initialize the main form
        'Note that you shoul add every time/resource consuming 
        '   tasks on the New of the main form, not on the Load.
        StartUp.MainForm = New Form2

        'Now lets change the MessageLoop base form, from the splash form to the main form
        StartUp.appContext.MainForm = StartUp.MainForm

        'Here, all "heavy" tasks have to be donne...

        'Make the spash form TopMost and show the main form 
        '(here the Load Event tasks of the mainform will be donne)
        StartUp.SplashForm.TopMost = True

        'Now you can close the spash... the app wont end...
        RaiseEvent SplashInitDonne()

        'Nothing else keeps the user waiting...
        StartUp.MainForm.ShowDialog()

    End Sub


REMEMBER
With this code, if you initialize heavy data on the Load Event of your MainForm, neither you'll see the Spash or the MainForm while that data is been initialized...
Try to initialize everything on the constructor (New).

Alex :p
 
Did you tryed it?

I'm pretty sure...
As long as I know, the fact you application have 10.000 dll's it doesn't matter if we're regarding the application start...
They will only consume resources when they will be initialized...

At the Sub Main time, no library is initialized...

Try it and give me some feedback, ok?

Alex :p
 
The problem is not my application dlls, but the .NET plataform initialization...

I think we are talking diferent things right? :)

HINT: .NET Plataform = .NET Enterprise plataform (driver), required to any computer to run any .NET application (size: about 28MB). THIS is the issue am talking about...

Não confundas as coisas :P
 
Last edited:
The entire .Net framework is not loaded into memory on application startup though - only the core runtime and then any dlls that are required by the application as they are needed. This means if you launch a splash screen from a sub main and do minimal code at this point then the number of dlls loaded should be kept to a minimum. While the splash screen is displayed load the main form and at this point other dlls can get loaded for the 1st time (data, security, xml etc).
 
Right, but it's that: "only the core runtime and then any dlls that are required by the application as they are needed" that consumes some great seconds to open my 60kb application (before the splash screens can appear) on a computer with no Visual studio .NET framework but with the 28MB .NET framework "driver" 1.1... Althought if I close the program and run it again it will load faster, as all dll's and stuff are already resident in memory, go figure... :)
 
Last edited:
A work-around could be to creat an oldfashioned vb6 or unmanged C++ application that shows a splash screen and then starts the main application, closing the splash screen (and itself) when the main application has finished loading.

But loading the .net framework to show the 1th form (without any .net apps loaded previously) takes about 1-2 seconds on my rig (1 GB RAM, 3ghz p4) so it shouldnt be that much of a problem if the form / main doesnt do anything fancy before showing the splash screen.

You might take a look at this splashscreen project for reference:
http://www.codeproject.com/csharp/PrettyGoodSplashScreen.asp
 
A common solution for getting the first .NET app to start up faster is to make a dummy app that does nothing and run it on system startup so the framework is always loaded.
 
Damn... Developers are really imaginative guys... :D:D:D

If the framework were allways resident in memory the complains where about how much resources it would take... as not, now is because it takes a couple os seconds to start the first time... :( go figure...

Alex :p
 
Back
Top