首先在窗體上放一個button和一個picturebox
private void button1_Click(object sender, EventArgs e)
{
//開啟執行緒
System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ThreadStart(this.Result));
pictureBox1.Visible = true;
button1.Enabled = false;
thread.Start();
}
private void Result()
bool ok = this.Do();
this.BeginInvoke(new System.Threading.ThreadStart(delegate()
if (ok) MessageBox.Show("成功", "提示");
else MessageBox.Show("失敗", "提示");
pictureBox1.Visible = false;
button1.Enabled = true;
}));
private bool Do()
System.Threading.Thread.Sleep(10000);
return true;
首先在窗體上放一個button和一個picturebox
private void button1_Click(object sender, EventArgs e)
{
//開啟執行緒
System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ThreadStart(this.Result));
pictureBox1.Visible = true;
button1.Enabled = false;
thread.Start();
}
private void Result()
{
bool ok = this.Do();
this.BeginInvoke(new System.Threading.ThreadStart(delegate()
{
if (ok) MessageBox.Show("成功", "提示");
else MessageBox.Show("失敗", "提示");
pictureBox1.Visible = false;
button1.Enabled = true;
}));
}
private bool Do()
{
System.Threading.Thread.Sleep(10000);
return true;
}