I am new to uwp and I am trying to learn how to make a background task. I tried to follow the instruction I have found online but cannot seem to get it working. I am not getting an explicit error but my background task is not writing to the debug console. Any help would greatly be appreciated.
This is my main xaml
This is my mainpage class
This is my Background Task in the Windows Runtime Component Project("MyBackgroundTask")
This is my manifest
This is before I press the button
This is after I press the button
Currently, you are using ApplicationTrigger for your BackgroundTask. This will allow you to start executing your backgroundtask programmatically.
But you need to call ApplicationTrigger.RequestAsync or ApplicationTrigger.RequestAsync(ValueSet) to start invoking your background task.
So, store your trigger globally, and call trigger.RequestAsync
after registration(e.g. in another button click event handler) will solve the problem:
ApplicationTrigger trigger;
...
private async void btnTrigger_Click(object sender, RoutedEventArgs e)
{
await trigger.RequestAsync();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With