2

I have an application with a splashscreen. When the splashscreen disappears, the window opens maximizend for a fraction of a second and then my application goes back to the background (like it's minimized). Why does this happen? My form has WindowState = Maximized enabled.

public Main()
{
    //Splashscreen and new window
    initializeWindow();
}

 public void SplashScreen()
{
    Application.Run(new SplashScreen());
}

 private void initializeWindow()
{
    //Start new Thread which shows Splash Screen
    Thread t = new Thread(new ThreadStart(SplashScreen));
    t.Start();
    //Wait 3 seconds
    Thread.Sleep(3000);
    InitializeComponent();
    //Initialize form
    t.Abort();
    //Abort and make main form the top form
    //TopMost = true; <-- I commented this because it makes other applications not open unless if I minimize the window
}
Markinson
  • 2,077
  • 4
  • 28
  • 56
  • [Right way](http://stackoverflow.com/a/15836105/1997232) of doing splash-screen. ["Left" way](http://stackoverflow.com/a/32469582/1997232) (the one you are using as it seems). – Sinatr Sep 06 '16 at 12:43
  • [Show Splash Screen during Loading the Main Form](http://stackoverflow.com/a/32421479/3110834) – Reza Aghaei Sep 06 '16 at 13:58

1 Answers1

2

Pausing the main thread is not a "healthy" solution , I would advice to do this :

  1. Instead of opening the Main window open the splash screen form.
  2. In the splash screen form set a timer that closes it.
  3. In the FormClosed event of the splash screen open the Main window.
Balagurunathan Marimuthu
  • 2,927
  • 4
  • 31
  • 44
Youness
  • 1,468
  • 1
  • 9
  • 19