i have some code that is running on the main thread, as well as a secondary GCD thread which is processing some data. After the data is processed, i need to update the UI and preferably as soon as possible, so is it possible for me to move that to the main thread to be processed immediately? Thanks!
Asked
Active
Viewed 178 times
-1
-
1What you have tried? It is not very difficult you can easily find answer on internet. http://stackoverflow.com/questions/7905192/iphone-grand-central-dispatch-main-thread – CRDave Aug 17 '13 at 07:43
-
1http://stackoverflow.com/questions/12933397/sending-messages-from-background-thread-to-main-thread-on-ios – CRDave Aug 17 '13 at 07:46
-
1http://stackoverflow.com/questions/13502242/ios-how-to-get-background-thread-to-redraw-view-on-main-thread – CRDave Aug 17 '13 at 07:47
1 Answers
0
void es_dispatch_sync_on_main_thread(dispatch_block_t block)
{
if ([NSThread isMainThread]) {
block();
} else {
dispatch_sync(dispatch_get_main_queue(), block);
}
}

Elf Sundae
- 1,575
- 16
- 23