×

Discussion Board

Results 1 to 14 of 14
  1. #1
    Registered User
    Join Date
    Sep 2013
    Posts
    4

    PeriodicTask runs every 60 minutes on Lumia 920.

    Hi,
    according to msdn documentation: http://msdn.microsoft.com/en-US/libr...vs.105%29.aspx
    the periodic task is run "every 30 minutes (...) the execution time may drift by up to 10 minutes". However these are the times when my Lumia920 runs periodic task:
    7:30 PM
    8:36 PM
    9:51 PM
    10:51 PM
    12:00 AM
    01:07 AM
    02:08 AM
    and so on...

    more or less once every hour. My Lumia has the newest Amber update, GDR2.
    Is that device specific? Why is it 60 minutes instead of 30?
    I'm not doing anything in my background task, just logging to isolated storage and calling NotifyComplete(). The device was connected to AC power and strong wi-fi network (access point about 1m from the device).
    The background task is executed and all is fine but it's CONSISTENTLY executed every 60 minutes, not 30...

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    419

    Re: PeriodicTask runs every 60 minutes on Lumia 920.

    How many Background Tasks are there on your phone in total. It might be that some combined exceed the total execution time alotted by the system and so others get pushed back to the next time slot (according to documentation Background Tasks might not run at all when the system experiences heavy load). At least it's a possibility that should be checked. That being said I've not tested the scheduling on my 920 since Amber but I'd be willing to do so.

  3. #3
    Nokia Developer Champion
    Join Date
    Feb 2013
    Location
    Dublin, Ireland
    Posts
    475

    Re: PeriodicTask runs every 60 minutes on Lumia 920.

    I'll second what SB Dev is saying, the system makes no guarantee that your Background Task will fire every 30 minutes - and there can be a variety of reasons why you are seeing this behaviour.

    Even if you were seeing your Background Task fire every 30 minutes on your own personal/test device, it's not likely to wok that way 'in the wild'.

    The main things to worry about are... a) is your Background Task completing its work within the time limit and b) are you staying within the RAM limit

  4. #4
    Registered User
    Join Date
    Sep 2013
    Posts
    4

    Re: PeriodicTask runs every 60 minutes on Lumia 920.

    SB Dev: that's my everyday phone, so I have some running apps. Settings say there are currently 7 "allowed" background tasks, including my test task.

    theothernt: my task is definitely within time and memory limits. All it does is it writes the current time stamp to a file in isolated storage.

    So you're saying that periodic tasks run at random times and often don't run at all? Then what's the point? I can't use it for anything meaningful if I don't know if it will ever run on user's device... It seems that WP apps have really NO way of running code in the background...
    but... it seems that it's pretty reliable on my device, but runs every 60 minutes, not 30 as stated in the docs.

    If you want to test that, you can use this project:
    http://www.cli.di.unipi.it/~mura/BgTaskTest.zip

    it's not written by me, got it from msdn thread with similiar problems... no solution was found there. It really looks as if background tasks are fundamentally broken on WP devices...
    What's the use of having a bit of code which you don't know when will it run if ever? The users will blame the app that something's not working/updating.

  5. #5
    Nokia Developer Champion
    Join Date
    Feb 2013
    Location
    Dublin, Ireland
    Posts
    475

    Re: PeriodicTask runs every 60 minutes on Lumia 920.

    All of the apps in the Windows Phone Store that update either their Live Tile or their app's data work perfectly fine with this system-controlled schedule. If an app's tile isn't updated after 30 minutes, maybe it takes an hour, that's perfectly fine - as long as the tile is updated 'frequently enough', then the user is happy.

    Also, no app should function solely or rely on it's Background Task - it's supplemental to the app. A Background Task is really just a small, restricted process and not a full app in it's own right. If you're in the early stages of making an app, just know that the Background Tasks work fine and (Periodic Agent) run every 30mins to 1hr.

    Is there any specific kind of app you are hoping to make? myself and other users on this Message Board have apps in the Store which use most/all of the phones's API so between us, we can give real information on how things work.

  6. #6
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    419

    Re: PeriodicTask runs every 60 minutes on Lumia 920.

    You could try disabling other agents temporarily and check wether the behavior still occurs then. The general guidance on background agents by Microsoft has always been that they should not be relied upon for functionality central to your App but merely to allow for additional benefits to the user that are not timing critical.

  7. #7
    Registered User
    Join Date
    Sep 2013
    Posts
    4

    Re: PeriodicTask runs every 60 minutes on Lumia 920.

    theothernt: I want to alert the user when he'll be within a few kilometers from a given gps coordinate. I know that tracking apps can run in the background constantly but I don't want to track the user all the time as this would use too much battery and the app would be killed after 4 hours without user interaction anyway.
    Let's say the app would have a list of geo coordinates. I thought I could check in the periodic task how far is the user from each coordinate in the list. If he's closer than a given range (let's say 10km) - alert him. I want to check that 24/7. The given distance could be quite big so checking every 30 minutes would be ok but 60 is a bit too much...

    The second thing is getting appointments from the user's calendar. How can my app know that the user added a new appointment to the calendar without the user actually launching my app? I though I could just check for new appointments every 30 minutes.

  8. #8
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    419

    Re: PeriodicTask runs every 60 minutes on Lumia 920.

    Geofencing unfortunately can't be done reliably on WP at the moment. I fear the only options are to rely on the status quo with all troubles attached to it or to opt for a background tracking application. You would not have to keep tracking him permanently there but could instead simply define a timer that e.g. checks the location every 10 minutes. That should not give that much trouble with battery life. The 4 hours issue won't go away though.

  9. #9
    Nokia Developer Champion
    Join Date
    Feb 2013
    Location
    Dublin, Ireland
    Posts
    475

    Re: PeriodicTask runs every 60 minutes on Lumia 920.

    Further to what SB Dev has said, Geofencing is expected is in the next major release of Windows Phone early next year. iOS, Android and Windows 8.1 currently offer Geofencing support so WP8 really is the odd one out at the moment.

    But even though Geofencing isn't available right now, I would continue with your app as it could easily make sure of new Geofencing APIs if/when they appear in a few months. And in case you haven't already read it, the official docs have a good tutorial on how location tracking apps work in the background...

    http://msdn.microsoft.com/en-us/libr...v=vs.105).aspx

  10. #10
    Registered User
    Join Date
    Sep 2013
    Posts
    4

    Re: PeriodicTask runs every 60 minutes on Lumia 920.

    Just looked through the 8.1 sdk docs and that's exactly what I need. Oh, well, good to know that at least it will probably come in the next version of wp. However, I'll have to think of something else for the Nokia Create competition ;-) Thanks for all the help!

  11. #11
    Nokia Developer Champion
    Join Date
    Feb 2013
    Location
    Dublin, Ireland
    Posts
    475

    Re: PeriodicTask runs every 60 minutes on Lumia 920.

    Quote Originally Posted by RadekGers View Post
    Just looked through the 8.1 sdk docs and that's exactly what I need. Oh, well, good to know that at least it will probably come in the next version of wp. However, I'll have to think of something else for the Nokia Create competition ;-) Thanks for all the help!
    Best of luck ;-)

    And if you have any more questions, ask away!

  12. #12
    Super Contributor
    Join Date
    Jan 2009
    Location
    Melbourne, Australia
    Posts
    2,578

    Re: PeriodicTask runs every 60 minutes on Lumia 920.

    Interesting. Some testing on 820 found background task much more reliable.

  13. #13
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    419

    Re: PeriodicTask runs every 60 minutes on Lumia 920.

    I remember those tests and in many cases this works but it has never been guaranteed. Unfortunately it seems we now have prove that it won't always work reliably.

  14. #14
    Super Contributor
    Join Date
    Jan 2009
    Location
    Melbourne, Australia
    Posts
    2,578

    Re: PeriodicTask runs every 60 minutes on Lumia 920.

    Indeed! FYI, all. This post was "featured" this week: http://developer.nokia.com/Blogs/Com...red-dibo-post/

Similar Threads

  1. Saving data before exiting in PeriodicTask
    By vinayppatil in forum Windows Phone General
    Replies: 24
    Last Post: 2013-05-13, 08:39
  2. Updates for Lumia 920, Lumia 820 and Lumia 620
    By hamishwillee in forum News, Announcements and Job Listings
    Replies: 0
    Last Post: 2013-03-15, 02:13
  3. Replies: 1
    Last Post: 2011-10-04, 13:26
  4. Replies: 4
    Last Post: 2009-09-07, 08:15
  5. Adding Minutes
    By KirkConcepts in forum Mobile Java General
    Replies: 1
    Last Post: 2002-10-28, 12:38

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •