jueves, 11 de agosto de 2011

[C#] Simple Slpash Screen

What I'm doing here is a very simple splash screen, must clients wnats their applications to have a splash screen, even when there is really nothing that worth preloading, so if this is the case keep reading, if not go and find another post.

So basically what we do is, create a new Thread that will wrap a method called wait();
in the form_load, like this:


private void Form1_Load(object sender, EventArgs e)
{
ThreadStart ts = new ThreadStart(wait);
Thread t = new Thread(ts);
t.Start();
}


and then we create a method that will trigger the main form or application after a little wait, this gives the idea of "preloading" but without actually preloading anything.


public void wait()
{
Thread.Sleep(5000); //time to wait in milliseconds
MessageBox.Show("done loading"); // actions to take when the wait is done
}


and that's it.

Happy Coding!

No hay comentarios:

Publicar un comentario