1
votes

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:

  • register again with the same time in TimerTrigger
  • register new TimeTrigger with one per two days timer.

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?

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:

  • register again with the same time in TimerTrigger

or

  • register new TimeTrigger with one per two days timer.

Can someone help me to understand? :)

P.S I saw somewhere that re-registration in UWP 10 is not necessary, is it?

1

1 Answers

0
votes

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.

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.