I'm trying to create a timer for my C#/Xaml modern UI app (Windows 8.1).
I already saw this post : How do we set Timers in WinRT app? The solution which is given in this link works for me. The DispatcherTimer works fine.
But my problem isn't there. I don't understand why this solution doesn't works :
My code :
//First Try
System.Threading.AutoResetEvent autoEvent = new System.Threading.AutoResetEvent(false);
StatusChecker statusChecker = new StatusChecker(MyList);
System.Threading.TimerCallback tcb = statusChecker.CheckStatus;
//System.Threading.Timer myTimer = new System.Threading.Timer(tcb, autoEvent, 0, 5000);
System.Threading.Timer theTimer = new System.Threading.Timer(CheckStatus, autoEvent, 0, 5000);
I put it in the MainPage constructor. TimerTick launchs CheckStatus which launchs a Debug.WriteLine().
I beleived the Threading.Timer will be set in a different thread than the UI thread but, when I push a button, the timer stops to work.
Somebody knows why ?