Sam
Sam

Reputation: 42387

When does the first occurrence of a recurring timed BackgroundTask run?

If you register a BackgroundTask with a recurring TimeTrigger (OneShot set to false), when does the first occurrence run? After the first FreshnessTime minutes or before?

Upvotes: 0

Views: 36

Answers (1)

iandayman
iandayman

Reputation: 4467

Microsoft documentation states:

If FreshnessTime is set to 15 minutes and OneShot is false, the task will run every 15 minutes starting between 0 and 15 minutes from the time it is registered.

edit
I tested this a few times and it seems to run the first occurrence at anytime during the 15 minute period after registration. It then runs future occurrences at regular 15 minute periods based on 15 minutes from the start time of the previous run.

I'm not sure internally how the OS is scheduling the timer cycles but the answer to your question is not after, not before but during.

nb. You cannot get any timer background task to fire immediately.

Upvotes: 1

Related Questions