在iOS多任务处理中进入后台时线程的行为 [英] Behaviour of threads when entering background in iOS multitasking

查看:217
本文介绍了在iOS多任务处理中进入后台时线程的行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行一些测试时,我注意到当一个应用程序(没有后台特权,即voip,gps等)进入后台状态时,当时正在运行的所有后台线程(或并发NSOperations)似乎都被暂停了( (未终止),并且当应用程序进入前台时,它们会继续.

While running some tests I've noticed that when an app (with no background privileges, i.e. voip, gps, etc) enters the background state, any background threads (or concurrent NSOperations) running at the time seem to be paused (not terminated), and they continue when the app enters the foreground.

我看不到任何地方都记录了该线程行为.有人知道这种行为是否已定义并且可以依靠吗?

I can't see this thread behaviour documented anywhere. Does anyone know if this behaviour is defined and can be counted on?

如果重新打开应用程序时线程可以安全地继续运行,则不必取消任务或参与任务完成会很有用.尤其是对于复杂的操作.

It would be useful to not have to cancel tasks or get involved in task completion if the thread can safely continue when the app is re-opened. Especially for complicated operations.

任何信息都很好.谢谢!

Any info would be great. Thanks!

推荐答案

退出非多任务应用程序后,它会冻结在当前状态并留在内存中.但是,如果内存不足,用户从多任务栏上将其关闭,或者设备已关闭,则该应用程序将被终止,而不会发出警告.您可以放心,从后台返回的应用程序将像以前一样继续运行,但是在进入后台时应保存状态,以防该应用程序被关闭.

When a non-multitasking app is quit, it is frozen in its current state and left in memory. However, if memory is low, the user closes it from the multitasking bar, or the device is shut down, the app will be terminated without warning. You can trust that an application returning from the background will continue as it was before, but you should save the state when entering the background in case the app is shut down.

这篇关于在iOS多任务处理中进入后台时线程的行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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