1) handleClickEvent is called in the main thread when a button is clicked on the view.
2) I used dispatch_sync () because the following code, which updates the view user interface, cannot be executed until the variable in the backgroundProcessing method is evaluated.
3) I used dispatch_get_global_queue to get backgroundProcessing from the main thread. (according to the rule: usually put the background processing from the main thread and usually put the code that affects the user interface in the main thread).
My question is: the backgroundProcessing method hangs with the main thread until it is complete, since I'm using dispatch_sync?
EDIT: Based on the answer below, I implemented this solution:
- (void)handleClickEvent { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ [self backgroundProcessing]; dispatch_async(dispatch_get_main_queue(), ^{ [self updateUI]; }); }); }
this link: End calls
source share