[英]DispatcherTimer and real time WP7
I am creating a slot game. 我正在创建一个老虎机游戏。 When I get the win I want to make it show in my TextBlock from 0 to win count. 当我获得胜利时,我想使它显示在我的TextBlock中,从0开始计数。 To create that I am using DispatcherTimer. 为了创建我正在使用DispatcherTimer。
The problem is when eg my integer win = 50 and after I use DispatcherTimer in my TextBlock i see over 50, like 54, 56. 问题是,例如当我的整数赢= 50,并且在TextBlock中使用DispatcherTimer之后,我看到超过50,例如54、56。
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = new TimeSpan(0, 0, 0, 0, 200);
timer.Tick += new EventHandler(Timer_Tick);
if (win != 0)
{
timer.Start();
}
private void Timer_Tick(object sender, EventArgs e)
{
if (timerCount == win)
{
timer.Stop();
}
WinTextBlock.Text = timerCount.ToString();
timerCount++;
}
确保在开始时将timerCount分配为0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.