The concept of a splash screen doesn\'t strike me as something that should be so complicated, but I\'m having trouble getting the whole splash screen painted.
Let\'s
Like me you probably created this as an afterthought and do not want to go through all the heck of redesigning your code to fit multi-threaded architecture...
First create a new Form called SpashScreen, in the properties click on BackgroundImage and import whatever image you want. Also set FormBorderStyle to None so that you can't click on the x to close the screen.
public Form1()
{
InitializeComponent();
BackgroundWorker bw = new BackgroundWorker();
bw.WorkerSupportsCancellation = true;
bw.DoWork += new DoWorkEventHandler(bw_DoWork);
bw.RunWorkerAsync(); // start up your spashscreen thread
startMainForm(); // do all your time consuming stuff here
bw.CancelAsync(); // close your splashscreen thread
}
private void bw_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker worker = sender as BackgroundWorker;
SplashScreen ss = new SplashScreen();
ss.Show();
while (!worker.CancellationPending) //just hangout and wait
{
Thread.Sleep(1000);
}
if (worker.CancellationPending)
{
ss.Close();
e.Cancel = true;
}
}
This does not support progress bar or any fancy stuff but I am sure it can be tweaked.