當我啓動計時器..timel正常增加..但一旦我停止計時器,即調用click_TimerStop函數,並再次啓動計時器... timel變量遞增timel + = 2 ..當我重複..它增加TIMEL工藝+ = 3..and它的推移和...我怎麼糾正呢?..如何正確增加變量?
DispatcherTimer clktimer = new DispatcherTimer();
private void click_TimerStart(object sender, RoutedEventArgs e)
{
clktimer.Start();
clktimer.Interval =new TimeSpan(0,0,1);
clktimer.Tick +=clktimer_tick;
}
private int timel = 0;
private void clktimer_tick(object sender, object e)
{
timel++;
timerSecond.Text = timel.ToString();
}
private void click_TimerStop(object sender, RoutedEventArgs e)
{
clktimer.Stop();
}