3
votes

In my application it takes some time to loan my initial screen(1-2 mins). Since it has so many controls to be filled by Database.

So I need to have a splash screen, it will load(probably with a progress bar) and stays while main form loads. Means in background I need to load main form (better with out showing)

Only main window finishes loading, it notifies to splash, the splash will go off and main will be visible.

I tried to achieve above with several way but no success.

Any one can help me ?

4
Doesn't it work: just create a window with progress bar before starting to load the main form? - Vlad
do a quick google search, you will be surprised how many good results you get - Bek Raupov
I did Google but most of example are talking about only showing splash, not giving time to do a lengthy process to run back ground. - Buddhi Dananjaya

4 Answers

1
votes
FormSplash splash = new FormSplash();

this.BeginInvoke(
    new MethodInvoker(
        () =>
        {
            splash.Show();
        }
    )
);

// main form code here

// at end of loading code
splash.Close();

The above code belongs in Form_Load of the main form.

0
votes

There are a couple of good approaches discussed at Show a splash screen at once (in fact to me this and the other question appear to be duplicates).

0
votes

The best way and using the API is

  SplashScreen splash = new SplashScreen("splashscreen.jpg");
  splash.Show(false);
  splash.Close(TimeSpan.FromMilliseconds(2));
  InitializeComponent();