wp8.1 C#技巧: 计时器

时间:2023-03-09 09:34:23
wp8.1 C#技巧: 计时器

public MainPage()
{
this.InitializeComponent();
this.timer = new DispatcherTimer();//新建委托时间实例
timer.Interval = new TimeSpan(0, 0, 0, 0, 200);//设置计时的刻度
timer.Tick += OnTimerTick;//监视增加计时间事件
timer.Start();//计时开始
}
void OnTimerTick(object sender, object e)
{
Data.Value += 0.2m;
this.txtValue.Text = string.Format("{0}s", Data.Value);
}
DispatcherTimer timer;