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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:09:07+00:00 2026-05-30T22:09:07+00:00

I start my ASIHTTPrequest synchronously in a separate thread like this : //inside this

  • 0

I start my ASIHTTPrequest synchronously in a separate thread like this :

//inside this start method I create my ASIHTTPRequest and start it
dispatch_async(dispatch_get_global_queue(0, 0), ^{
    [process start];
});

But the completionBlock is still fired on the main thread. Can one keep the execution of the completionBlock in the same thread as where the request was started?

The only thing i can come up with to solve this is to define a dispatch queue and manually execute the completionBlock in the same thread, thus holding a reference to a created queue. But that does not solve it directly because you would pass for a freaking little moment in the main thread before redirecting the rest of the code to the created dispatch queue.

Does someone have a better solution?

EDIT: The same is also true for AFNetworking completion blocks…

  • 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-30T22:09:08+00:00Added an answer on May 30, 2026 at 10:09 pm

    Ok, to answer my own question :
    ASIHTTPRequest framework does not have an option to start completion blocks in a different thread.

    Instead one can use the AFNetwork framework. Here you have two properties on any type of AFOperation called ‘successCallbackQueue‘ and ‘failureCallbackQueue‘. Where you can add a predefined ‘dispatch_queue_t‘ to handle the execution of success and failure blocks.

    Hope this will help others with the same problem!

    UPDATE : Example

     dispatch_queue_t requestQueue = dispatch_queue_create("requestQueue", NULL);
     AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:yourRequest];
     operation.successCallbackQueue = requestQueue;
     operation.failureCallbackQueue = requestQueue;
     [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
        // add code for completion
     } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        // add code for failure
     }];
     [operation start];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I download a URL like this one: http://tinyurl.com/csr2xc7 then ASIHTTPRequest's temporaryFile is created
I start a .Net server side program on my local workstation, but soon it
/* I start with this: */ <Report> <prop1>4</prop1> <prop2>2255</prop2> <prop3>true</prop3> <prop4>false</prop4> <prop5>true</prop5> </Report> /*
To start off, I'd like to say I'm rather unfamiliar with the Windows linking
I got some question is using ASIHTTPRequest to tracking Upload/Download progress This is the
is there some new framework additions for doing something like this in iOS 4
Start here: scroll to bottom footer I'm unable to create a hover effect on
I've checked for other questions relevant to this, but the only answer is Use
I start learning some java concurrency concept ans put in use. But one of
Start a new Silverlight application... and in the code behind (in the Loaded event),

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.