wp8.1 C#技巧: 计时器

时间:2014-12-10 22:30:20   收藏:0   阅读:219

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;

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!