I want to add a splash screen to my WPF app in a new thread (because my animated splash screen hangs when the data for Main window is loading). Code:
SplashScreenWindow splashScreenWindow = null;
Thread newWindowThread = new Thread(() =>
{
splashScreenWindow = new SplashScreenWindow();
splashScreenWindow.ShowDialog();
});
newWindowThread.SetApartmentState(ApartmentState.STA);
newWindowThread.IsBackground = true;
newWindowThread.Start();
data loading...
_mainWindow.Show();
splashScreenWindow.Close();
My problem is that the program closes when I close the splash screen.