I want to create a background task in windows phone 8.1 and I want to use a timer task in order to count down a specific time. Therefore, I try using DispatcherTimer class to do this. However, it shows up an error when I try to create it:
DispatcherTimer timer = new DispatcheTimer();
The error is: An exception of type 'System.Exception' occurred in TimerTaskBackground.winmd but was not handled in user code
Additional information: The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD))
Can anyone explain to me the problem here? and Are there other ways to countdown a specific time to do something?
Use ThreadPoolTimer
, more info https://msdn.microsoft.com/en-us/library/windows/apps/windows.system.threading.threadpooltimer
User contributions licensed under CC BY-SA 3.0