Skip to content

Instantly share code, notes, and snippets.

@jeksys
Created July 13, 2011 19:32
Show Gist options
  • Save jeksys/1081144 to your computer and use it in GitHub Desktop.
Save jeksys/1081144 to your computer and use it in GitHub Desktop.
dispatch_async Useful pattern to avoid blocking the main thread
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