[UWP]进程内服务完成BackgroundTask [英] [UWP] In-process ServicingComplete BackgroundTask

查看:217
本文介绍了[UWP]进程内服务完成BackgroundTask的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


是否可以在进程中运行ServicingComplete后台任务(在应用更新时运行)?我的印象是这是不可能的,因为文档说没有必要注册它,但你必须将
它放在清单文件中。那当然不能用于进程,因为你不能再添加一个入口点。

那么,我应该把它作为一个进程外后台任务吗?


我认为我需要这样的后台任务,因为我的UWP应用程序会在第一次运行时自动注册15分钟的后台任务。应用程序关闭后,该任务必须继续运行。我被告知,稍后应用程序更新时,我必须取消注册并在ServicingComplete任务中重新注册
后台任务,以使我的15分钟后台任务保持活动状态。

是这推理仍然正确吗?

解决方案


首先是对于进程内后台活动,您不要设置TaskEntryPoint。将其留空可启用默认入口点,Application对象上的一个新受保护方法,名为
<强> OnBackgroundActivated ()。
这里的进程后台任务中提到了这一点:创建并注册进程内后台任务。所以你不需要
担心这个。您可以尝试在项目中创建进程内ServicingComplete后台任务。有关&ServlingComplete后台任务的更多信息,请参阅:在您的UWP应用更新后运行
a后台任务
。 


祝您好运,


Roy


Hi,

Is it possible to have a ServicingComplete background task (one which runs when an app updates) running in-process? I have the impression that this is not possible because the documentation says that it is not necessary to register it but you have to put it in the manifest file. That of course doesn't work for in-process since you cannot add an entry point then.
So, should I make it an out-of-process background task?

I think I need such background task because my UWP app automatically registers a 15 minute background task the first time it runs. That task must keep on running after the app closes. I am told that when later the app updates I have to de-register and re-register the background task in a ServicingComplete task in order to keep my 15 minutes background task active.
Is this reasoning still correct?

解决方案

Hi,

The first thing is that for in-process background activities you do not set TaskEntryPoint. Leaving it blank enables the default entry point, a new protected method on the Application object called OnBackgroundActivated(). This is mentioned in the In-process background task here:Create and register an in-process background task. So you don't need to worry about this. You could just try to create a in-process ServicingComplete background task in your project. For more information about ServicingComplete background task, refer here:Run a background task when your UWP app is updated

Best regards,

Roy


这篇关于[UWP]进程内服务完成BackgroundTask的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆