Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
Posted (edited)

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...

Edited by EFileTahi-A
Posted

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

Live as if you were to die tomorrow. Learn as if you were to live forever.
Gandhi
Posted (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.

 

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...

Edited by EFileTahi-A
Posted

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...

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...

   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

Software bugs are impossible to detect by anybody except the end user.
Posted

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

Software bugs are impossible to detect by anybody except the end user.
Posted (edited)

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

Edited by EFileTahi-A
  • Administrators
Posted
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).

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted (edited)
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... :) Edited by EFileTahi-A
Posted

I would like to see that too...

 

The only way I see is if you're running your app on a 200mhz computer... :p

Software bugs are impossible to detect by anybody except the end user.
Posted

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

Nothing is as illusive as 'the last bug'.
Posted
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.
"Who is John Galt?"
Posted

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

Software bugs are impossible to detect by anybody except the end user.
  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...