开发者

Behaviour of threads when entering background in iOS multitasking

开发者 https://www.devze.com 2023-02-06 05:12 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消