Sure... Add new WindowsForm
to your project, call it SplashImageForm
. Add PictureBox
control to it, and add the image you want in it. Resize the form, set these SplashImageForm
properties:
FormBorderStyle - None
ShowInTaskBar - false
StartPosition - CenterScreen
Then you want to show that form before Form1 and close it after the timeout has expired... Like so for example:
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
SplashImageForm f = new SplashImageForm();
f.Shown += new EventHandler((o,e)=>{
System.Threading.Thread t = new System.Threading.Thread(() =>
{
System.Threading.Thread.Sleep(2000);
f.Invoke(new Action(() => { f.Close(); }));
});
t.IsBackground = true;
t.Start();
});
Application.Run(f);
Application.Run(new Form1());
}
EDIT
Now, there is new thread which blocks on System.Threading.Thread.Sleep(2000)
for 2 seconds, and the main thread is allowed to block on Application.Run(f)
as it is supposed to, until the SplashImageForm
isn't closed. So the image gets loaded by the main thread and the GUI is responsive.
When the timeout ends, Invoke()
method is called so the main thread which is the owner of the form closes it. If this wasn't here, Cross threaded exception would be thrown.
Now the image is shown for 2 secs, and after it Form1 is shown.