Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
Is it possible to show a splash screen as soon as the user attempts to open an app? On XP there is a long wait (the first time I run the app), I assume while dot net loads.
Posted 10-Dec-12 8:44am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
LizHundy at 10-Dec-12 14:00pm
   
I have built a splash screen. It opens before my main form is created, from the Main() method. But first time I run the app there is a long delay before it appears. I thought this might be due to dotnet, but I suppose it could be a virus checker causing the delay.
Jason Gleim at 10-Dec-12 14:21pm
   
When you launch an application, if the .net framework isn't running, it must startup. Then, it must load your application's manifest file and parse it. Then it loads your main assembly, compiles it, and starts running it. If it has to jump to another class it will stop and compile it. Remember that .net apps are JIT compiled on-the-fly from MSIL to the binaries as the app is run.
 
You can improve initial startup with some tricks like delay-loading assemblies your app relies on but which may not be needed till later and avoiding things like initializing classes outside of a constructor (at the class level) when you declare the object. (declaring private myClass myObject = new myClass(); will initialize and create myObject as soon as the class which contains that call is initialized whereas if you do:
private myClass myObject;
void MyContainingClass()
{
myObject = new myClass();
}
The myObject doesn't get explicitly created until the containing class is explicitly created. Which if you do the same thing for the MyContainingClass object, you would put the new MyContainingClass() call after you have displayed the splash screen. Make sense?
 
Also, are you using the static Main() function as your entry point or is it Form1.Main()? If you use the static one, you have much more control over your application start up. If you use the form-based one, then everything behind your form must initialize before that function is called.
LizHundy at 10-Dec-12 15:09pm
   
Thanks Jason. That is helpful information.
I am using static Main()
Perhaps I need a separate non-dotNet app to show the splash screen and then invoke my dotnet application.
jibesh at 10-Dec-12 17:37pm
   
I dont understand why you are worrying about .net and non .net. Since your main application taken long time to start-up because of several reason not necessarily .Net but may be for various other reason, I would suggest you to start a splash screen and update(write) something on the splash screen to let the user know that system is performing some operation.
 
There are good number of splash screen samples are available in code project have a look at it. some are
http://www.codeproject.com/Articles/158/Adding-a-splash-screen-to-your-dialog-based-applic
http://www.codeproject.com/Articles/30103/NET-Splash-Screen-Component
http://www.codeproject.com/Articles/6511/Transparent-Splash-Screen
LizHundy at 11-Dec-12 4:48am
   
Hi jibesh. You miss the point. I start the splash screen before my app begins to initialise. But the splash screen does not appear as soon as the user clicks to start the app. On a slow computer running XP there is considerable delay before the splash screen appears. I assume that tihs delay is waiting for .NET to load.
I have a very nice splash screen from Code Project. This is a valuable resource. :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.150326.1 | Last Updated 10 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100