What happens if a block is asynchronously executing on a background queue when the user quits the app? Will it be terminated? Is it down to me to handle in –applicationWillTerminate:
?
I'm not talking about long running tasks.. just wondering if there is an inherent danger in doing anything that could lead to inconsistent state asynchronously?
All threads (GCD created or not) are terminated when an app exits, so yes, the block will not be run (ever) if it hasn't already. If there's work being done that needs to complete before the app can safely exit then you can wait for that in -applicationWillTerminate, but it's really not a good idea to set things up that way since your app could also be force quit by the user and -applicationWillTerminate may never run.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With