欧美一区二区三区,国内熟女精品熟女A片视频小说,日本av网,小鲜肉男男GAY做受XXX网站

winform多線程異步更新UI

呂致盈2年前53瀏覽0評論

winform多線程異步更新UI?

首先在窗體上放一個button和一個picturebox

(picturebox visible為false)這個多線程的目的是點擊按鈕后圖片正常的運行,另一線程在睡眠10秒后在執(zhí)行。

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;

}

java ui線程,winform多線程異步更新UI