The splash screen is a common feature in many desktop applications. A splash screen is used to provide feedback to the user as the application initializes. If your application does not have a long initialization process, it does not need a splash screen, and should not have one (the splash screen can become annoying after a while, especially if it is not necessary).
If you are in need of a splash screen, the BizArk framework provides the capability to show the splash screen on a thread while you initialize your application in Main (the starting point in Windows applications). You do not need to worry about any of the threading issues, BizArk takes care of all that for you. If you are interested in learning how to display a form on a separate thread, check out the source code in SplashScreen.cs, BizArkWinForms project.
The BizArk SplashScreen class provides the following capabilities:
- Displays a custom splash screen on a separate thread to allow for initialization on the main thread.
- Provides a mechanism to send progress to the splash screen.
- Can fade in and out to give a more finished, polished look.
- Set a minimum time to show the splash screen.
The splash screen is easy to use. Just create your splash screen as a standard Form. In your programs Main method (usually in Program.cs), create a new instance of Redwerb.BizArk.WinForms.SplashScreen and send in the type for your custom splash screen. When you are ready to show your splash screen call ShowSplash and when you are done with it call HideSplash.
If you want to send status updates to the splash screen, your form will need to implement the ISplashScreen interface. The BizArk SplashScreen object will route the status to the correct thread so that you don’t need to worry about cross threading issues (problematic with WinForms).
Below is an example of calling the splash screen from the RedwerbEntry project (a test project available in the BizArk Framework download):
SplashScreen splash = new SplashScreen(typeof(Splash));
splash.FadeInTime = 500;
splash.FadeOutTime = 500;
splash.MinShowTime = 3000;
splash.ShowSplash();
//todo: remove sleep (used for testing purposes).
splash.Status = "Sleeping";
System.Threading.Thread.Sleep(cmdLine.RunTime);
//todo: initialize the application including creating an instance of the main form.
//var frm = new MyForm();
//var frm.Initialize(); // or whatever you need to do to prepare the form before display.
splash.Status = "Hiding";
splash.HideSplash(true);
//Application.Run(frm);
BizArk is available for download on the CodePlex website, http://bizark.codeplex.com.