Task parallelism is not supported prior to IOS 4.0
Determine if the current device supports task parallelism
Before the app is in the background state and before it is suspended, you can call UIApplication's Beginbackgroundtaskwithname:expirationhandler: method to delay the suspend to perform some important tasks, such as saving user data. Because the system is assigned a limited amount of time to perform background tasks for the app, it is called before the background task times out or the system forces the Kill app.endBackgroundTask:方法来结束掉后台任务。App 对象的 backgroundTimeRemaining 属性用来查询可用的剩余的执行时间。启动后台任务时,beginBackgroundTaskWithExpirationHandler: 的返回值是这个任务的唯一标识,把这个唯一标识传递给 endBackgroundTask: ,就可以终结掉这个任务。
Example:
Create a task in the background, and then hand this task to a dispatch queue for this task to be executed synchronously, where Bgtask is the member variable of the class