locked
Simple example of Timed background task for Store app? RRS feed

  • Question

  • I downloaded the sample app (which has 4 different types of background tasks) and looked over the Quickstart C# app, but that one only shows bits and pieces of how to do it (and not where to put the code, nor did it have a place to download a full working example!). I saw the Registration and Unregistration bits in the sample app, I updated the manifest, etc, but I'm having trouble putting it all together, like running in a debug mode to trigger every minute (like WP does), syntax to call the Register and Unregister, where to check for the backgroundapp already running, etc.

    Windows Phone background example seemed pretty straightforward compared to doing it for a regular Store app - to me anyway!

    Can someone point me in the direction of simple project code that runs a timed background app at an interval?

    Saturday, February 1, 2014 5:31 AM

Answers

  • You've already found the sample code for this, and it demonstrates everything you mention (except the every-minute debug mode, which doesn't exist). If you are having problems with your specific code please post a minimal repro to your SkyDrive which demonstrates what you are doing and where you have issues.

    Syntax for Registering is in the Register the background task to run section of the Quickstart, as is syntax to check if the background task is already running. You would call these together as you want to check if the task is already running so that you don't restart it again if so.

    --Rob

    Saturday, February 1, 2014 6:08 AM
    Moderator

All replies

  • You've already found the sample code for this, and it demonstrates everything you mention (except the every-minute debug mode, which doesn't exist). If you are having problems with your specific code please post a minimal repro to your SkyDrive which demonstrates what you are doing and where you have issues.

    Syntax for Registering is in the Register the background task to run section of the Quickstart, as is syntax to check if the background task is already running. You would call these together as you want to check if the task is already running so that you don't restart it again if so.

    --Rob

    Saturday, February 1, 2014 6:08 AM
    Moderator
  • Am I correct in understanding that the only ways to have a background task run periodically (like every 15-30min) is to have the user approve it as a Lock Screen app or by using RSS feeds?
    Saturday, February 1, 2014 12:12 PM
  • Correct: the time trigger request the app be on the lock screen. RSS is not relevant to this.

    Depending on what you need the timer for a maintenance trigger may help and doesn't require lock-screen access.

    Saturday, February 1, 2014 4:00 PM
    Moderator
  • I just need to regularly (every 15-30min) call an http request and send the result through a toast notification using a Windows Store App. How can this be done? I can't push it from a server because the 2nd part of the app also sends system memory information with the toast.

    • Edited by JefffRozar Saturday, February 1, 2014 11:21 PM
    Saturday, February 1, 2014 11:16 PM
  • Why don't you want to be on the lock screen? That is how the user can control which apps have this sort of permission so rogue apps cannot drain the batteries without the user's knowledge.

    What do you mean by sending system memory information? System information isn't generally available to Windows Store apps. It sounds like you may be trying to write something that would be better off as a desktop app.

    --Rob

    Sunday, February 2, 2014 5:46 AM
    Moderator
  • Ok, look into the Lock Screen, it seems that will work just fine. Thanks!

    Sunday, February 2, 2014 11:59 AM