110,567
社区成员
发帖
与我相关
我的任务
分享
private void btAuto_1_Click(object sender, EventArgs e)
{
//auto(time1, btAuto_1, bt1, stationNum1, stationSum1, timer1);
if (btAuto_1.Text == "自动")
{
btAuto_1.Text = "手动";
//自动模拟车辆运行
while (stationNum1 < stationSum1)
{
Random rd = new Random();
//时间为40-100秒之间
time1 = rd.Next(5, 10);
timer1.Enabled = true;
//timer的间隔为1秒
timer1.Interval = 1000;
t.Start();
??????????????????????????????????
bt1_Click(bt1, e);
}
}
else if (btAuto_1.Text == "手动")
{
btAuto_1.Text = "自动";
}
}
private void timer1_Tick(object sender, EventArgs e)
{
if (time1 > 0)
{
this.label_time_1.Text = time1.ToString();
time1--;
}
else
{
timer1.Stop();
}
}
bool waitting = false;
private void btAuto_1_Click(object sender, EventArgs e)
{
//auto(time1, btAuto_1, bt1, stationNum1, stationSum1, timer1);
if (btAuto_1.Text == "自动")
{
btAuto_1.Text = "手动";
//自动模拟车辆运行
while (stationNum1 < stationSum1)
{
waitting = true;
Random rd = new Random();
//时间为40-100秒之间
time1 = rd.Next(5, 10);
timer1.Enabled = true;
//timer的间隔为1秒
timer1.Interval = 1000;
t.Start();
while(waitting) Application.DoEvents();//暂停
bt1_Click(bt1, e);
}
}
else if (btAuto_1.Text == "手动")
{
btAuto_1.Text = "自动";
}
}
private void timer1_Tick(object sender, EventArgs e)
{
if (time1 > 0)
{
this.label_time_1.Text = time1.ToString();
time1--;
}
else
{
timer1.Stop();
waitting = false;//设置标记
}
}