→ tryPTT:ㄜ..似乎有點高深XD 05/02 23:31
我覺得最好的作法如下
public static frmSplash g_frmSplash;
public static Form g_frmMain;
public static Thread g_ThreadShowSplash;
g_ThreadShowSplash = new Thread(new ThreadStart(ShowSplash));
g_ThreadShowSplash.IsBackground = true;
g_ThreadShowSplash.Start();
g_frmMain = f;
Application.Run(f);
public static void ShowSplash()
{
if (g_frmSplash == null)
g_frmSplash = new frmSplash();
g_frmSplash.ShowDialog();
}
private void frmMain_Load(object sender, EventArgs e)
{
if (Program.g_ThreadShowSplash != null &&
(Program.g_ThreadShowSplash.ThreadState ==
System.Threading.ThreadState.Running ||
Program.g_ThreadShowSplash.ThreadState ==
System.Threading.ThreadState.Background))
{
//Program.g_ThreadShowSplash.Abort();
Program.g_frmSplash.Invoke(new MethodInvoker(delegate
{
Program.g_frmSplash.Close();
}));
Program.g_frmSplash = null;
}
}
沒有排版,不好意思,不用 Thread.Abort 的原因是因為會噴出 AbortException
※ 引述《tryPTT (NULL)》之銘言:
: 各位好
: 小弟最近在學C#..看到書上有提到一個東西
: 叫做SplashScreen
: 就是類似開啟Word會先出現的那個矩形小版面~~~
: 只是我不知道該怎麼實作..
: 只覺得應該是在Form的Load事件去操作
: 但不知道該怎麼寫
: 希望各位給予提示....感謝^^
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.160.212.92