jump to navigation

How to make a splash screen. December 8, 2005

Posted by Christian López Espínola in CSharp, Programming.
trackback

When we execute some applications, we see a splash screen with the logo of the program on it.

The computer user thinks that if there’s no new window in his monitor, computer is not working.

By that, we should show something when the application is loading his data structures.

How can we make it? Using threads. In CSharp we have to include the System.Threading namespace.

At our Main function we have to declare a thread like follows:

Thread th= new Thread (new ThreadStart(Splash));

Splash is an static function we will see later.

Then we start thread’s execution, and we initialize our structures. After that, we kill the secondary thread:

th.Start();

//initialize structures…

th.Abort();

Finally we start our main window:

Application.Run(mainForm);

Our Splash function could be like follows:

public static void Splash()

{

SplashForm sf = new SplashForm();

sf.ShowDialog();

}

If our structures load fast, the splash screen will not can visible. We can make it visible with a thread sleep. The time that thread sleeps is taken in milliseconds:

Thread.Sleep(4000);

Now our applications will seem more professional. :D

Comments»

1. El Vargas - December 8, 2005

Good article. ;)

2. LAME ATTACK - December 6, 2007

SPUNK MUFFINS

3. isim - July 29, 2008

thanks
for turkish(teşekkür ediyorum, minnettarız)

4. Christian López Espínola - July 29, 2008

@isim
I had to ask to a turkish friend… :-P

You are welcome, and thanks for commenting

If you want to follow me, I’m now at http://penyaskitodice.wordpress.com

5. nomly - January 11, 2009

thanks for the article,its great