當然...添加新的WindowsForm
到您的項目,把它SplashImageForm
。將PictureBox
控件添加到它,並添加您想要的圖像。調整的形式,設置這些SplashImageForm
屬性:
FormBorderStyle - None
ShowInTaskBar - false
StartPosition - CenterScreen
然後你想顯示Form1上之前的形式和超時後關閉它已過期......像這樣的例子:
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());
}
編輯 現在,有一個新線程在System.Threading.Thread.Sleep(2000)
上阻塞2秒,主線程被允許在Application.Run(f)
上按原樣阻塞,直到SplashImageForm
未關閉。所以圖像被主線程加載並且GUI響應。
當超時結束時,Invoke()
方法被調用,所以窗體所有者的主線程關閉它。如果這不在這裏,將會拋出跨線程異常。
現在圖像顯示2秒,然後顯示Form1。
你的意思是像一個閃屏? – BoltClock
您正在創建一個啓動畫面。看看這個:http://www.google.com/search?gcx=w&sourceid=chrome&ie=UTF-8&q=c%23+splash+screen –