In my application i need to synchonize some data on a TimeTriggered intervall. Now i have built a BackgroundTask with TimeTrigger, inside this task i im running a BackgroundTransfer operation. This works, but i havesome questions about that.
Is this a good solution, orare there better ones for this scenario?
There are some mysterious execution things. If i deploy the app as debug version to my phone, everything works like a charm, all Transfer operations are completed within one execution of the BackgroundTask, this takes +/- 15 minutes. Now if i deploy the app as release version to my phone, the BackgroundTask transfers data only for 1-2 minutes and stops, till the next execution from the TimeTrigger is fired. Why is there a difference or why is this?
edit: Resource intensive Task is not an option for me, the app is built on WinRT store app. When this is a limitation from backgroundTask, how then can i perform such an operation from the background?
edit2: @kiewic, im calling it awaitable, will change that, but what is then the difference, as this is executet in the background task?
You have to distinguish between the BackgroundTask and the BackgroundTransfer. These are two different things.
The job of your background task is to start your background transfers. The job of your BackgroundTransfer (upload or download operation) is to perform the transfer independently of your application.
The transfer doesn't need to take place within the BackgroundTask. If you call await on the start of the background transfer, you will wait until the upload is complete. If you don't, you will continue executing within your task (e.g. if you are in a loop, you can begin to build and start the next upload).
Once you have started a background transfer, it is managed independently of your app or any task by the OS. It can even survive the phone being restarted.