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 6918443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:51:35+00:00 2026-05-27T09:51:35+00:00

Below is a sample function where I try to run one main group, wait,

  • 0

Below is a sample function where I try to run one main group, wait, then run two other background tasks on separate threads, wait, then return a value altered in the general blocks shown below. What is shown below is my guess at how to do this. It works if I run these blocks all in one block. It fails when I separate the blocks. Does anyone have an example of how they accomplish something similar? Thanks in advance for your help.

-(NSString *)sampleFunction:(NSString*)inputString
{
 __block NSString *returnString;

 dispatch_group_t mainGroup = dispatch_group_create();
 dispatch_group_t otherGroup = dispatch_group_create();

 void (^firstBlock)(void) = ^(void)
 {
  ...
 };

 void (^secondBlock)(void) = ^(void)
 {
  ...
 };


 void (^thirdBlock)(void) = ^(void)
 {
  ...
 };

 dispatch_group_async(oneGroup, dispatch_get_global_queue(0, 0), firstBlock);

 dispatch_group_wait(oneGroup, sizeof(int));

 dispatch_group_async(otherGroup, dispatch_get_global_queue(0, 0), secondBlock);
 dispatch_group_async(otherGroup, dispatch_get_global_queue(0, 0), thirdBlock);

 dispatch_group_wait(otherGroup, sizeof(int));

 dispatch_release(userGroup); 
 dispatch_release(otherGroup);

 return returnString;
}
  • 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-27T09:51:36+00:00Added an answer on May 27, 2026 at 9:51 am

    There are lots of different ways to do this, but the most conceptually simple (or at least obvious) way would be to create a group for each stage of your “pipeline”, then have the completion callback for group A schedule the work on group B which also has a completion callback which schedules the work on group C.

    The key here is not to actually “wait” for a group to complete – that’s unnecessary. Groups can have completion blocks that will get run automatically when the last block in that group finishes (see dispatch_group_notify()), and this is a good way of creating “fan in” points where you’ve fanned out a bunch of work in the group.

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

Sidebar

Related Questions

I have some sample webservice like below, <WebMethod()> _ Public Function ExecuteCMD() As Boolean
i have written a sample program.below: #include<iostream> #include<string> #include<set> using namespace std; int main()
Below is sample code to create a radio button element with Yes/No options in
In the below code sample, what does {0:X2} mean? This is from the reflection
I've put together a small code-sample below (Currently in C# 3.5 but would also
I have a IObservable [named rows in the sample below] from Reactive extensions framework
I've been learning C#, and I'm trying to understand lambdas. In this sample below,
In the sample code below I am dividing by zero which when I step
The code below shows a sample that I've used recently to explain the different
Below I have written a sample program that I have written to learn about

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.