jeudi 21 juillet 2016

dispatch_async on main_queue?

I have seen this code snippet:

dispatch_async(dispatch_get_main_queue(), ^{
    [self doSomeNetworkStuff];
});

This doesn't look like making much sense to me.

EDIT: To clarify the conditions of my question:

  • The call to dispatch_async is performed from the main thread.
  • The sent message doSomeNetworkStuff is the heavy lifting worker task.
  • ... and is not only the UI-updating task.

Dispatch, sure, but using the main queue would just pull the dispatched task back to the ui thread and block it.

Please, am I missing something? Thanks.

Aucun commentaire:

Enregistrer un commentaire