Request for background task in UWP more than one, is it necessary?
Request for background task in UWP more than one, is it necessary?
I make a library with several background tasks for UWP 8.1/10 (desktop/mobile).
I have 3 background tasks but I talk about one of them. When the app starts, I see permission request dialog:
await BackgroundExecutionManager.RequestAccessAsync();
I click to allow and continue registration of background task, this part works excellent. Every 15 minutes I see my task in Output. It works perfectly.
So, in near future, I want to change execution time while background task is working it creates the same task with another TimerTrigger
(depends on some conditions, but it can happen), for example:
TimerTrigger
TimerTrigger
TimeTrigger
I know about:
Note Universal Windows apps must call RequestAccessAsync before registering any of the background trigger types.
So, I need use await BackgroundExecutionManager.RequestAccessAsync()
every time when I try to register any of background task, does I understand it right?
await BackgroundExecutionManager.RequestAccessAsync()
In other words, I do it every time when I change/re-register TimerTrigger
for the first time, then when I need to do it when:
TimerTrigger
TimerTrigger
or
TimeTrigger
Can someone help me to understand? :)
P.S I saw somewhere that re-registration in UWP 10 is not necessary, is it?
1 Answer
1
So, I need use await BackgroundExecutionManager.RequestAccessAsync() every time when I try to register any of background task, does I understand it right?
Yes. Check the remarks of BackgroundExecutionManager.RequestAccessAsync
method, this must be called before registering any background tasks.
BackgroundExecutionManager.RequestAccessAsync
I saw somewhere that re-registration in UWP 10 is not necessary, is it?
If you mean this method is not necessary, actually re-registration you mentioned here should be a process that first un-register and register again. It should have nothing special with register. Only starting with Windows 10, it is no longer necessary to call this method from the UI thread.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.