Complicated background work in UWP, is it real?

牧云@^-^@ 提交于 2019-12-11 17:09:18

问题


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:

  1. Every 15 minutes send POST request to the server
  2. Every 1 minute check some data
  3. 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?


回答1:


The short answer,it is not complicated.

Every 15 minutes send POST request to the server

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.

Every 1 minute check some data

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.

Run via push notification a long-running tcp/ip connection which can run about 1 hour (how long can it run?)

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.



来源:https://stackoverflow.com/questions/50668776/complicated-background-work-in-uwp-is-it-real

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!