去掉tt.Join();
因为tt.Join()阻塞了主线程,所以界面会卡.
可以这样写代码:
private void Form1_Load(object sender, EventArgs e)
{
ProgressBar.CheckForIllegalCrossThreadCalls = false;
}
private void btnSearch_Click(object sender, EventArgs e)
{
this.progressBar1.Maximum = 9000;
progressBar1.Minimum = 0;
progressBar1.MarqueeAnimationSpeed = 1000;
Thread tt = new Thread(new ThreadStart(LongProcess));
tt.Start();
// tt.Join();
}
private void LongProcess()
{
for (int i = 0; i < 9000; i++)
{
this.progressBar1.Value = i;
}
}
侯垒
|
老鸟四级
|园豆:3435
|
2008-08-20 11:05