简体   繁体   English

后台任务会永远运行吗?

[英]Background tasks run forever?

I am a little confused with background tasks. 我对后台任务有些困惑。 I've finished making one with the help of this tutorial . 本教程的帮助下,我已经完成了一个。 The tutorial says this: 本教程说:

Create a background task class and register it to run when your app is not in the foreground 创建一个后台任务类,并注册它以在您的应用程序不在前台时运行

However, my background task runs even if it is in the foreground. 但是,我的后台任务即使在前台也可以运行。

Is this intended behavior, that it runs whether or not the app is in the foreground? 这是否是预期的行为,无论应用程序是否在前台都可以运行? Is the presentation just not clear? 演讲不清楚吗?

Background tasks run asynchronously on a thread pool thread, no matter what. 无论如何,后台任务都在线程池线程上异步运行。 Which means it doesn't matter whether your app is in the foreground or not. 这意味着您的应用程序是否在前台都没有关系。 Once it kicks, its running. 一旦启动,它就会运行。

Great links on BG tasks here - https://msdn.microsoft.com/en-us/windows/uwp/launch-resume/monitor-background-task-progress-and-completion . 有关BG任务的重要链接-https: //msdn.microsoft.com/zh-cn/windows/uwp/launch-resume/monitor-background-task-progress-and-completion

Great paper on background tasks at https://www.microsoft.com/en-us/download/details.aspx?id=27411 . 有关后台任务的出色论文, 网址https://www.microsoft.com/zh-cn/download/details.aspx?id=27411 Still relevant even though its 8.1. 即使它的8.1仍然有意义。

a background thread is drawn from the thread pool, and it meant to run in the background. 从线程池中提取了一个后台线程,它打算在后台运行。 your UI thread is the main thread, likely it is run on the foreground. 您的UI线程是主线程,可能在前台运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 让任务在控制台应用程序的后台永久运行 - Have tasks permanently run in background in Console application 如何在 IHostedService 的后台同时运行多个任务 - How to run multiple tasks simultaneously in the background of a IHostedService 如何在ios中永远运行后台服务以同步数据 - How to run background service in ios forever for syncing of data 如何在 UWP 后台应用程序中同时运行 2 个任务? - How to make 2 tasks run simultaneously in a UWP background app? “触发并忘记”异步任务或在后台运行它的正确方法 - Proper way to "fire and forget" async Tasks or run it in background Task.WhenAll是否在后台线程并行运行任务 - Does Task.WhenAll run Tasks in background thread parallel 可以运行2个后台任务-Windows Phone 8.1 Universal应用程序? - Possible to run 2 background tasks - Windows Phone 8.1 Universal app? 如何在wp8应用程序中定期运行两个后台任务? - how to run two background tasks periodically in wp8 apps? Autofac 无法处理后台任务 - Autofac not working with background tasks WinRT中的后台任务 - Background Tasks in WinRT
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM