
splash screen is created upon application startup and is ended after the the main Window class's initialization code executes. Professional-looking applications geenrally use splash screens to let their users know where the application is in the initiliazation process. This generic splash screen is different from the SplashScreen class provided by Microsoft (.NET Framework 3.5 SP1), which displays only an image file and only in the center of the screen.
Sometimes, adding splash screens can be problematic. For instance, suppose you've added a WPF window to your project and spiced it up with some animation effects, which you implemented directly in XAML. Then, you specified the Startup event handler in the app.xaml file, like this:
<Application x:Class="MyNamespace.App" Startup="Application_Startup">
In the App class, you added a property:
private static Thread threadSpashScreen;
public static Thread ThreadSpashScreen()
{
get { return app.threadSpashScreen };
}
You also added code for two methods as follows:
private void Application_Startup(object sender, StartuoEventArgs e)
{
threadSpashScreen = new Thread(ExecuteSplashScreen);
threadSplashScreen.SetAppartmentState(AppartmentState.STA);
. . .
threadSplashScreen.Start();
}
private void ExecuteSplashScreen()
{
YourSplashScreen splScr = new YourSplashScreen();
. . .
splScr.ShowDialog(); //Modal dialog box
}
At the end of the main Window class’s initialization code, you've called
Abort():
App.ThreadSplashScreen.Abort();
This works without any visible problems. Or so you think.