I just want to confirm my reasoning that doing a dispatch_sync from the UI thread(main thread) using the main queue is utterly useless.
To add to that, async would be just as useless but with the illusion that it is useful because it doesn’t block.
Let me know.
Thanks
The
dispatch_syncto the same queue is not only useless, but it will lock your app.dispatch_syncsays “dispatch something, but don’t proceed on this queue until the other queue responds”. That obviously can’t happen if the “other” queue (that we’re waiting for it to complete the dispatched block) is the same one as “this” queue (which is blocked until that other queue responds). Your app will freeze, waiting for itself!On the other hand,
dispatch_asyncto the same queue you’re currently on is not generally a very useful construction, but at least it won’t freeze. I’ve seen some awkward code that useddispatch_asyncto itself as a way of saying “as soon as I finish some series of actions, I then want to do something else”. I’ve rarely seen this dispatching asynchronously to itself in situations where it couldn’t be done more elegantly another way, but I have seen it.