Add SplashScreen to your application
Date Posted | Product | Author |
---|---|---|
08/27/2013 | Telerik UI for WinForms | Georgi Georgiev |
Problem
You have a big application which takes long time to load initially and you want to display proper indication to your end users of the ongoing process.
Solution
Create a splash screen which will be shown to your users while the heavy work is done behind the scenes.
First of all we will need a simple *ShapedForm *which will play the role of our SplashScreen. All we need to do is add a PictureBox which will hold our Logo:
Then, we will need our MainForm *which will do the heavy lifting. In this simulation we will just sleep the main thread for *2000 milliseconds which seems like a normal case scenario:
The main logic will be happening in our Program.cs/Program.vb file, this is where our forms will be created and disposed. First of all we will need to run the SplashForm *on a separate thread, this will enable it to run independently of the main thread which is supposed to be busy handling the heavy operations. This way UI operations such as animations will not be interrupted because the UI thread will not be blocked. After running the thread with the *SplashForm, we can create the MainForm and subscribe to its Load event, where we consider the loading is completed and we will close the SplashForm and let our application run normally:
For VisualBasic you will have to create a new Module named Program, go to your project settings -> Application -> Uncheck “Enable application framework” -> from the dropdown above (“Startup objects”) choose Program:
A complete solution in C# and VB.NET can be found here.