Created
July 13, 2011 19:32
-
-
Save jeksys/1081144 to your computer and use it in GitHub Desktop.
dispatch_async Useful pattern to avoid blocking the main thread
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Nested invocations provide asynchronous callbacks | |
• Communication between subsystems | |
-(IBAction)onClick:(NSButton *)sender | |
{ | |
dispatch_async(account->queue, | |
^{ | |
NSImageRep *image = renderAccountStatement(account); | |
dispatch_async(dispatch_get_main_queue(),^{ | |
[imagedraw]; | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment