locked
Does BackgroundTask run even when the app is in not running state

    Question

  • Hi All,

    I'm on developing offline capable window store app. I idea in my mind is to store all the data in sqlite database and write a background task which triggers on constant time intervals to sync the data in sqlite tables to sqlserver data with a web service as a mediator. But the thing is i want this background task to be running even if the app is in notrunning state.

    Can this background task behave like a windows service which does this job of syncing seamlessly.

    Or do anyone of you has some other breakthrough idea on to how to develop a offline capable app which syncs the data even if the app isn't running.

    For your info i'm developing it using C# and xaml

    thanks
    noor


    • Edited by noor syed Wednesday, April 02, 2014 2:59 PM typo
    Wednesday, April 02, 2014 2:59 PM

Answers

  • It really depends on the data.

    For most cases I'd sync the SQLite data while the app was running rather than shuffling it off to the background. Unless you have large deltas this shouldn't be too much of a problem.

    You can also do a full background transfer, but that will work on a file basis rather than a per-record basis so isn't suited for SQLite data (unless you want to transfer a full database). One possibility would be to extract the updates to a file and transfer that to a web service which can unpack the changes to your SQL server.

    --Rob

    • Marked as answer by noor syed Friday, April 04, 2014 6:50 AM
    Wednesday, April 02, 2014 11:30 PM
    Owner

All replies

  • Yes, the purpose  of background tasks is to run when the app is not actively in the foreground.

    They have limited resources to run in, so you won't be able to do heavy calculation or major data transfer. See the background tasks whitepapers for more detail.

    Introduction to Background Tasks http://go.microsoft.com/fwlink/p/?linkid=227329

    Background Networking http://go.microsoft.com/fwlink/p/?linkid=241645

    --Rob


    Wednesday, April 02, 2014 3:07 PM
    Owner
  • Hi Rob,

    thanks for the quick response,

    so background task shld not the heavy duty of data transfer,

    any better way out to transfer sqlite data to remote server when device goes online.

    thanks
    noor

    Wednesday, April 02, 2014 3:46 PM
  • It really depends on the data.

    For most cases I'd sync the SQLite data while the app was running rather than shuffling it off to the background. Unless you have large deltas this shouldn't be too much of a problem.

    You can also do a full background transfer, but that will work on a file basis rather than a per-record basis so isn't suited for SQLite data (unless you want to transfer a full database). One possibility would be to extract the updates to a file and transfer that to a web service which can unpack the changes to your SQL server.

    --Rob

    • Marked as answer by noor syed Friday, April 04, 2014 6:50 AM
    Wednesday, April 02, 2014 11:30 PM
    Owner