Reputation: 341
I just watched this raywenderlich.com video and took this screenshot of the code in question (@ 22:30).
I'm wondering how mainQueue.async
finished after defaultQueue.async
despite being put on what I thought was a higher priority queue (defaulting to userInteractive
or userInitiated
, but regardless higher than default
, right?). I watched the entire video and felt like I had a great grasp on everything until seeing that. Would anyone please be able to explain? Thanks so much in advance.
Upvotes: 0
Views: 70
Reputation: 3439
There's not enough of the code in the screen shot to really see what's going on, but I think the issue is this:
The main queue is special; unlike all other dispatch queues, blocks added to the main queue get dispatched by the application's main run loop. All other dispatch queues execute blocks on any available thread.
So while a block you queue to run in the background will start almost immediately, anything you queue to run on the main thread has to wait until the main run loop cycles, and must wait its turn alongside timers, user input events, and so on.
Upvotes: 1