c#计时器没有停止

时间:2015-01-30 05:21:52

标签: c# timer

计时器以button1;

开头
private void button1_Click(object sender, EventArgs e)
    {
        timer1.Interval = 1;
        timer1.Enabled = true;
    }

定时器功能应该工作,直到我点击STOP按钮

private void timer1_Tick(object sender, EventArgs e)
{
   Keyboard.KeyDown(Keys.D9);
   Thread.Sleep(1);
   Keyboard.KeyUp(Keys.D9);
   Thread.Sleep(1);
   Keyboard.KeyDown(Keys.D1);
   Thread.Sleep(1);
   Keyboard.KeyUp(Keys.D1);
}

Button2是“停止”按钮但是计时器在我关闭应用程序之前没有停止,如果我点击超过五或十,有时会停止但有时它永远不会停止

 private void button2_Click(object sender, EventArgs e)
    {
        timer1.Enabled = false;
        MessageBox.Show("timer stop");
    }

0 个答案:

没有答案