Performs the specified block asynchronously and notifies you if the process is about to be suspended.
- iOS 8.2+
- tvOS 9.0+
- watchOS 2.0+
- Mac Catalyst 13.0+Beta
A string used in debugging to indicate the reason the activity began. This parameter must not be
nilor an empty string.
A block containing the work to be performed by the activity. The block has no return value and takes the following parameter:
A Boolean indicating whether the process is about to be suspended. If the value is
YES, the process is about to be suspended so you should take whatever steps are needed to stop in progress work. If it is
NO, start the planned tasks.
Use this method to perform tasks when your process is executing in the background. This method queues
block for asynchronous execution on a concurrent queue. When your process is in the background, the method tries to take a task assertion to ensure that your block has time to execute. If it is unable to take a task assertion, or if the time allotted for the task assertion expires, the system executes your block with the parameter set to
YES. If it is able to take the task assertion, it executes the block and passes
NO for the expired parameter.
If your block is still executing and the system need to suspend the process, the system executes your block a second time with the
expired parameter set to
YES. Your block must be prepared to handle this case. When the expired parameter is
YES, stop any in-progress tasks as quickly as possible.