private void bgw_PLC_DoWork(object sender, DoWorkEventArgs e)
{
while (!bgw_PLC.CancellationPending)
{
if (bgw_PLC.CancellationPending)
{
e.Cancel = true;
} if (this.textBox1.Text == "1")
{
//执行start按钮
button1_Click(sender, e);
bgw_PLC.CancelAsync(); //开始计时
timerPLCStart = System.DateTime.Now;
timer1.Enabled = true;
}
}
}
我用timer1.Enabled = true;去开启PLC为什么无效?
请教原因
{
while (!bgw_PLC.CancellationPending)
{
if (bgw_PLC.CancellationPending)
{
e.Cancel = true;
} if (this.textBox1.Text == "1")
{
//执行start按钮
button1_Click(sender, e);
bgw_PLC.CancelAsync(); //开始计时
timerPLCStart = System.DateTime.Now;
timer1.Enabled = true;
}
}
}
我用timer1.Enabled = true;去开启PLC为什么无效?
请教原因
其他两个函数可以。
少一句:this.timer1.Tick +=new EventHandler(timer1_Tick);