DispatcherTimer and real time WP7

113 views Asked by At

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. To create that I am using DispatcherTimer.

The problem is when e.g my integer win = 50 and after I use DispatcherTimer in my TextBlock i see over 50, like 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++;

        }
1

There are 1 answers

0
Schullz On

Make sure that timerCount is assigned to 0 at the beginning