在做c# winform 主窗体开了两个窗体Form(窗体里面有个定时器Forms.timer),希望两个窗体的定时器同时进行,可是执行的时候第二个执行完成,第一个才开始执行,没有两个一起执行的效果,如何解决,c#的三个线程我都试过,不好用,谁有好的解决方法?求大神
主窗体button1按钮,开了两个相同的form2
private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
f2.timer1.Enabled = true;
f2.Show();
Form2 f3 = new Form2();
f3.timer1.Enabled = true;
f3.Show();
}
下面是form2里面的一个timer,里面有个定时器
int i = 0;
private void timer1_Tick(object sender, EventArgs e)
{
timer1.Enabled = false;
for (int j = 0; j < 20; j++)
{
i++;
Thread.Sleep(1000);
Application.DoEvents();
textBox1.Text = i.ToString();
}
// Thread.Sleep(500);
}