Drstein99 Posted January 20, 2005 Posted January 20, 2005 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. Quote www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
EFileTahi-A Posted January 20, 2005 Posted January 20, 2005 (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 January 20, 2005 by EFileTahi-A Quote
techmanbd Posted January 20, 2005 Posted January 20, 2005 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 Quote Live as if you were to die tomorrow. Learn as if you were to live forever. Gandhi
EFileTahi-A Posted January 20, 2005 Posted January 20, 2005 (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 January 20, 2005 by EFileTahi-A Quote
techmanbd Posted January 20, 2005 Posted January 20, 2005 ah, ok. I thought he was loading his own dll's or something like that. Quote Live as if you were to die tomorrow. Learn as if you were to live forever. Gandhi
IngisKahn Posted January 20, 2005 Posted January 20, 2005 One thing you can do is run ngen on your app so it doesn't have to be compiled everytime. Quote "Who is John Galt?"
AlexCode Posted January 21, 2005 Posted January 21, 2005 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 Quote Software bugs are impossible to detect by anybody except the end user.
EFileTahi-A Posted January 21, 2005 Posted January 21, 2005 AlexCode, are you sure about this? That this code you wrote will be loaded before the .NET plataforms initialization? (ODD!!!) or We are talking about diferent things? Quote
AlexCode Posted January 21, 2005 Posted January 21, 2005 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 Quote Software bugs are impossible to detect by anybody except the end user.
EFileTahi-A Posted January 21, 2005 Posted January 21, 2005 (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 January 21, 2005 by EFileTahi-A Quote
Administrators PlausiblyDamp Posted January 21, 2005 Administrators Posted January 21, 2005 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). Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
EFileTahi-A Posted January 21, 2005 Posted January 21, 2005 (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 January 21, 2005 by EFileTahi-A Quote
Administrators PlausiblyDamp Posted January 21, 2005 Administrators Posted January 21, 2005 What code are you executing before your splash screen is displayed? Any chance you could post your startup code to see if anyone could spot a potential bottleneck? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
AlexCode Posted January 21, 2005 Posted January 21, 2005 I would like to see that too... The only way I see is if you're running your app on a 200mhz computer... :p Quote Software bugs are impossible to detect by anybody except the end user.
Wile Posted January 22, 2005 Posted January 22, 2005 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 Quote Nothing is as illusive as 'the last bug'.
IngisKahn Posted January 22, 2005 Posted January 22, 2005 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. Quote "Who is John Galt?"
AlexCode Posted January 22, 2005 Posted January 22, 2005 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 Quote Software bugs are impossible to detect by anybody except the end user.
Drstein99 Posted February 23, 2005 Author Posted February 23, 2005 Has anyone resolved this issue? I don't know what nGen is either - what does that do? Quote www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
AlexCode Posted February 23, 2005 Posted February 23, 2005 About nGen... - Open the Visual Studio .NET Command Prompt. - Write: nGen The help will show... For a MSDN Reference look at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpgrfnativeimagegeneratorngenexe.asp Alex :p Quote Software bugs are impossible to detect by anybody except the end user.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.