Kenny
Kenny

Reputation: 1142

Background task cancelled (ExecutionTimeExceeded)

I got a background task that downloads a few JSON data files that works perfectly when I call it using Visual Studio. When the background task is called using the UserPresent trigger at startup it gets cancelled (ExecutionTimeExceeded.)

Is there anything I can do to run the background task without any limit?

Upvotes: 0

Views: 420

Answers (1)

Romasz
Romasz

Reputation: 29792

Probably not, the time limit is dependent on trigger type, and as MSDN says it can vary from 30 seconds to 10 minutes:

CPU quotas: Background tasks are limited by the amount of wall-clock usage time they get based on trigger type. Most triggers are limited to 30 seconds of wall-clock usage, while some have the ability to run up to 10 minutes in order to complete intensive tasks. Background tasks should be lightweight to save battery life and provide a better user experience for foreground apps. See Support your app with background tasks for the resource constraints applied to background tasks.

The backgroundtask should be a lightweight code - maybe you can redirect file download procedure to background transfer service and do some of heavy job in main app. You may also try with MaintenanceTrigger, there is a chance that constraints are lower for this one, but it fires once phone is connected to AC.

Upvotes: 1

Related Questions