user1744147
user1744147

Reputation: 1145

Win 10 UAP: TimeTrigger and Application.OnBackgroundActivated

I am trying to use background task with TimeTrigger. I do not provide entry point that leads to Application.OnBackgroundActivated be called on OS version 332 or higher.

I have two questions:

  1. It seems there is no param in Application.OnBackgroundActivated to indicate it is called as a result of time trigger. Specifically in my app it is can be called for other triggers and use cases. I need some way to determine that it is time trigger activation.

  2. TimeTrigger can only be set for 15 minutes minimum. Is there way for debugging purposes shorten this time?

Upvotes: 0

Views: 232

Answers (1)

Grace Feng
Grace Feng

Reputation: 16652

For your first question, if your app has multiple background tasks, you can use BackgroundActivatedEventArgs.TaskInstance.Task.Name to identify which task is being initiated. You can refer to the official Background activation sample to see how it works.

For your second question, yes there is way for debugging purposes shorten this time. You can find the Lifecycle Events when debugging your app, after a TimeTrigger is registered, you can see the following lifecircle event:

enter image description here

Just click this item, the TimeTriggerTask will be fired immediately.

Upvotes: 1

Related Questions