Usually I work with Android but now I need to make background application/library/service in UWP.
So, I need three background tasks/jobs/services:
- Every 15 minutes send POST request to the server
- Every 1 minute check some data
- Run via push notification a long-running tcp/ip connection which can run about 1 hour (how long can it run?)
I am confused, is it possible for UWP?
The short answer,it is not complicated.
Background tasks can run as frequently as every 15 minutes, and they can be set to run at a certain time by using the
TimeTrigger
. For more info see Run a background task on a timer.Based on battery life considerations if
FreshnessTime
is set to less than 15 minutes, an exception is thrown when attempting to register the background task. For long running background Task please check Run background tasks indefinitely official document.You could use
PushNotificationTrigger
to enable them to provide real-time communication with the user even when the app is not in the foreground.For creating the Background Task, You could refer this document. And this is official code sample that you could refer.