I have some timers as member :
Windows::UI::Xaml::DispatcherTimer^ m_pollingTimer;
I create the timer as below and on timer tick i execute some async task :
m_pollingTimer = CreateAndStartDispatcherTimer(500ms, &MainPage::OnPollingTick);
While reloading/suspending application i stop the timers as below :
Stop all timers :
for (auto timer : {m_pollingTimer})
{
if (timer)
timer->Stop();
}
What happens to background tasks if I stop the timer itself? - Does it stop the background tasks as well or waits for the task to finish?
Reload Application :
bool MainPage::Reload(Platform::Object^ param)
{
auto rootFrame = dynamic_cast<Windows::UI::Xaml::Controls::Frame^>(Window::Current->Content);
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == nullptr)
{
// Create a Frame to act as the navigation context and associate it with
// a SuspensionManager key
rootFrame = ref new Windows::UI::Xaml::Controls::Frame();
}
auto type = rootFrame->CurrentSourcePageType;
try
{
return rootFrame->Navigate(type, param);
}
catch (Platform::Exception^ ex)
{
throw ex;
}
}
After stopping the timers i reload the UI.
Will the background thread keep running or stopped already?