I have a callback which might come from any thread. When I get this callback, then I would like to perform a certain task on the main thread.

Do I need to check whether I already am on the main thread – or is there any penalty by not performing this check befora calling the code below?

dispatch_async(dispatch_get_main_queue(), ^{
   // do work here
});

4 Answers
4

Leave a Reply

Your email address will not be published. Required fields are marked *