110,567
社区成员
发帖
与我相关
我的任务
分享
private void ShowProcessBar()
{
Form2 myProcessBar = new Form2();
myProcessBar.Show();
Application.DoEvents();
}
private void button4_Click(object sender, EventArgs e)
{
Thread thdSub = new Thread(new ThreadStart(ThreadFun));
thdSub.Start();
int i, j, k;
if (true)
{
for (i = 0; i <= 10000; i++)
{
for (j = 0; j <= 100000; j++)
{
k = j;
}
}
}
thdSub.Abort();
thdSub = null;
}
进度条可以正常显示滚动,代码也可以继续执行下去,但是无法关闭进度条窗体。求解。。。
private void ShowProcessBar()
{
Form2 myProcessBar = new Form2();
myProcessBar.ShowDialog();
}
private void ThreadFun()
{
MethodInvoker mi = new MethodInvoker(ShowProcessBar);
this.BeginInvoke(mi);
Thread.Sleep(500);
}
private void button4_Click(object sender, EventArgs e)
{
Thread thdSub = new Thread(new ThreadStart(ThreadFun));
thdSub.Start();
//int i, j, k;
//if (true)
//{
// for (i = 0; i <= 10000; i++)
// {
// for (j = 0; j <= 100000; j++)
// {
// k = j;
// }
// }
//}
}
Form2中无代码