Running frequent background tasks on Windows Phone 8.1

The Windows Phone platform offers the BackgroundTasks framework. I can register my task like this:

builder.TaskEntryPoint = TaskName;
var trigger = new TimeTrigger(15, false);

builder.SetTrigger(trigger);
builder.Register();

      

The problem is that the minimum TimeTrigger interval is ~ 15 minutes, which is quite long for my application. I need to have a task that runs every 1-2 minutes in the background. Is this possible on Windows Phone?

+3


source to share


2 answers


It is not possible for BackgroundTasks to run at minimum interval. As you said, the minimum interval is 15 minutes.

This is an OS limitation that prevents developers from creating battery drain applications.



You always have workarounds like having a PushNotificationTrigger and being able to send a push notification to your device every minute. (I think some people can do this with ScheduledToastNotification

) but I would not recommend it.

+3


source


AFAIK with the official API - TimeTrigger cannot be triggered this often. Note that on WIndows Phone the spacing is even greater ( MSDN ):

Windows has a built-in timer that runs background tasks at 15-minute intervals. Please note that on Windows Phone the interval is 30 minutes.



I doubt this will be possible due to batteries / limitations. Perhaps you can keep your app in the foreground and disable the lockscreen (using DisplayRequest).

Also you can try to start the timer along with getting defaffal in BackgroundTask. I have not tried this, there will surely be many problems (CPU, memory and other limitations), I am not sure if this does not contradict the certification requirements, and of course it does not guarantee that your BackgroundTask will not run out of OS.

+2


source







All Articles