0

I'm building a small app on my windows phone, and I'm having trouble with the dispatcher timer.

Everytime the page is loaded, the dispatcher is being ran over another time.

Basically I got a countdown, when ever the user returns to the mainpage (the countdown), the dispatcher timer is being ran again, this mean, that the countdown is going down twice as fast.

Jazerix
  • 4,729
  • 10
  • 39
  • 71

1 Answers1

1

Basically the DispatcherTimer is a class that creates a new Thread. So when your page gets reloaded, it creates a new thread. So it is advised to dispose the DispatcherTimer class everytime you navigate away from the class.

DispatcherTimer timer=new DispatcherTimer();


//OnNavigatedFrom(EventArgs e)
{
  timer=null;
}
Mani
  • 1,364
  • 14
  • 33
  • Even if you navigate to another page, the timer continues to tick! Even if you assign the Timer to another `new` instance in page constructor, the old one continues to tick. Please don't tell that microsoft doesn't suck. Your deal is the only way, if you need a timer to work on specific page only. – Vassilis May 11 '16 at 12:16