I want to use a background task for my UWP app.
The below code, is my back button click event in windows mobile-
private async void MainPage_BackRequested(object sender, BackRequestedEventArgs e)
{
var access= await BackgroundExecutionManager.RequestAccessAsync();
var task = new BackgroundTaskBuilder
{
Name="My task",TaskEntryPoint=typeof(backGroundTask.Class1).ToString()
};
trigger = new ApplicationTrigger();
task.SetTrigger(trigger);
task.Register();
//var result = await trigger.RequestAsync();
if (Frame.CanGoBack)
{
Frame.GoBack();
e.Handled = true;
}
}
public void Run(IBackgroundTaskInstance taskInstance)
{
_deferral = taskInstance.GetDeferral();
clearData();
count1 = 0;
getDownloadedSongs();
dispatcherTimer1.Tick += DispatcherTimer1_Tick;
dispatcherTimer1.Interval = new TimeSpan(0, 0, 3);
dispatcherTimer1.Start();
_deferral.Complete();
}
DispatcherTimer dispatcherTimer1 = new DispatcherTimer();
private async void DispatcherTimer1_Tick(object sender, object e)
{
try
{
clearData();
}
catch (Exception ex)
{
}
}
what is the way to do it with Extended execution in uwp ..specifically for windows mobile 10
Stefan Wick MSFT
ExtendedExecution will allow you to keep running and finish your task before you get suspended. Please take a look at the official sample for ExtendedExecution
Extended Execution has been in talks for quite a long now. You can definitely continue the app execution even when it is minimized. I don't have a working sample yet but you can get some insight by looking at the link here
来源:https://stackoverflow.com/questions/44551853/extended-execution-in-uwp