flutter 后台任务_快速后台任务

flutter 后台任务

Hi everybody, I’m Riccardo. Senior iOS Engineer at Bending Spoons, I breathe iOS development, both apps and tools and I love to share my knowledge with others

大家好,我是Riccardo。 Bending Spoons的高级iOS工程师,我负责iOS开发,包括应用程序和工具,我喜欢与他人分享我的知识

Last week, a question was running through our (virtual) office: how much time does iOS leave to the app to complete a background task?

上周,我们(虚拟)办公室里出现了一个问题:iOS留给应用程序多少时间来完成后台任务?

As often happens in the technology world, the documentation is not that precise. Also, there is a lot of misinformation that makes it hard to find the right answer: someone says 30" others 3'. So… I decided to run a small experiment to find out and here it is what I did and what I discovered.

正如技术界经常发生的那样,文档并不是那么精确。 另外,还有很多错误信息,很难找到正确的答案:有人说30“别人3'。所以……我决定进行一个小实验,以找出答案,这就是我所做的事情和发现的事情。

技术 (Technology)

The technology chosen to run this test is the old UIApplication.beginBackgroundTask(withName:expirationHandler:) . This method does two things:

选择运行该测试的技术是旧的UIApplication.beginBackgroundTask(withName:expirationHandler:) 。 此方法有两件事:

  1. It informs the OS that, once put into the background, the app needs more time to complete a long-running task.

    它告知OS,将其置于后台后,该应用需要更多时间才能完成长时间运行的任务。
  2. It returns an identifier that can be used to inform the OS that the task is completed (by invoking the UIApplication.endBackgroundTask(_:) method).

    它返回一个标识符,该标识符可用于通知OS任务已完成(通过调用UIApplication.endBackgroundTask(_:)方法)。

If we forget about calling the beginBackgroundTask method, the OS will assign something like 5" to complete the ongoing tasks and that could not be enough.

如果我们忘记调用beginBackgroundTask方法,则操作系统将分配5“之类的内容来完成正

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值