Skip to content

Instantly share code, notes, and snippets.

@markSci5
Created August 19, 2013 07:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markSci5/6266552 to your computer and use it in GitHub Desktop.
Save markSci5/6266552 to your computer and use it in GitHub Desktop.
GCD background and main thread task
//Start an activity indicator here
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//Call your function or whatever work that needs to be done
//Code in this part is run on a background thread
dispatch_async(dispatch_get_main_queue(), ^(void) {
//Stop your activity indicator or anything else with the GUI
//Code here is run on the main thread
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment