Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6719105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:03:11+00:00 2026-05-26T09:03:11+00:00

I have been using with success, grand central dispatch in my apps, but I

  • 0

I have been using with success, grand central dispatch in my apps, but I was wondering what is the real advantage of using something like this:

dispatch_async(dispatch_get_main_queue(), ^{ ... do stuff

or even

dispatch_sync(dispatch_get_main_queue(), ^{ ... do stuff

I mean, in both cases you are firing a block to be executed on the main thread, exactly where the app runs and this will not help to reduce the load. In the first case you don’t have any control when the block will run. I have seen cases of blocks being executed half a second after you fire them. The second case, it is similar to

[self doStuff];

right?

I wonder what do you guys think.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:03:12+00:00Added an answer on May 26, 2026 at 9:03 am

    Dispatching a block to the main queue is usually done from a background queue to signal that some background processing has finished e.g.

    - (void)doCalculation
    {
        //you can use any string instead "com.mycompany.myqueue"
        dispatch_queue_t backgroundQueue = dispatch_queue_create("com.mycompany.myqueue", 0);
    
        dispatch_async(backgroundQueue, ^{
            int result = <some really long calculation that takes seconds to complete>;
    
            dispatch_async(dispatch_get_main_queue(), ^{
                [self updateMyUIWithResult:result];
            });    
        });
    }
    

    In this case, we are doing a lengthy calculation on a background queue and need to update our UI when the calculation is complete. Updating UI normally has to be done from the main queue so we ‘signal’ back to the main queue using a second nested dispatch_async.

    There are probably other examples where you might want to dispatch back to the main queue but it is generally done in this way i.e. nested from within a block dispatched to a background queue.

    • background processing finished -> update UI
    • chunk of data processed on background queue -> signal main queue to start next chunk
    • incoming network data on background queue -> signal main queue that message has arrived
    • etc etc

    As to why you might want to dispatch to the main queue from the main queue… Well, you generally wouldn’t although conceivably you might do it to schedule some work to do the next time around the run loop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using this logic in C++ and VB with success, but am
I have been trying for this but no success. I am using PHP, HTML,
I have been using this code with great success to pull out the first
Sorry if this question is simple but I have been using node.js for only
I have been using the CodeIgniter system for a while now - but it
I have been using this copy method for quite a while, in lots of
I have been using ClojureBox with great success to learn both Clojure and emacs.
I have been using UIViewController s and initWithNibName with much success, basically using them
I have been using Sinatra for sometime now and I would like to add
I have been using this script for a while and suddenly it just stopped

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.