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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:16:46+00:00 2026-05-27T01:16:46+00:00

I want to write a method that does not block. The method doesn’t return

  • 0

I want to write a method that does not block. The method doesn’t return anything.
This is not over the web or anything – its all local to the device it is running on.

Basically, the calling method just wants some other object to take care of something. And once it tells it “Go do this”, the caller wants to get back to doing its own work instead of waiting for the object to finish executing the task.

I don’t want to use NSNotification.

EDIT: I want to be able to do this using frameworks available on iOS 3.1.2 and later

EDIT: Thanks for all the great replies – but I am unsure about which to choose. My requirements are simply that the calling method be able to send arguments to the called method, and return immediately without waiting for the result. Which would be the best solution?

  • 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-27T01:16:47+00:00Added an answer on May 27, 2026 at 1:16 am

    You use one of: libdispatch, NSOperation, add an NSInvocation or ‘perform selector on thread’ to a run loop, create a thread…

    Update

    It depends on the time and complexity of what you want to do. If it’s rather simple (e.g. simple text parsing), then just add it to the main run loop. If it takes more time (e.g. a download or opening a file), then you will want it off the main run loop.

    Create a thread

    You can use pthreads interfaces to create one or more threads to perform your work.

    One might choose pthreads for the greatest performance and control of any option in the list. Regarding performance: It requires that you will understand costs and the problems well. Creating threads is not trivial, so it’s good to reuse them or divide tasks well. Making and testing concurrent designs also takes a good amount of time.

    Personally, I use a more portable abstraction (over pthreads, specifically) for most of my multithreading needs. If portability is important, then you’ll likely want to use such an abstraction layer because the remainder of the options are not really seen outside of Apple’s systems.

    You could also use something like -[NSObject performSelectorInBackground:withObject:] for convenience with objc types.

    libdispatch

    (a.k.a. GCD)

    Although I read it not an option for you, I’ll write a brief overview regardless: Can be likened to a task/scheduler/thread pool abstraction layer over pthreads. This library is often used for concurrent tasks. It uses thread pooling for tasks, which may block or run asynchronously. Rather fast and simple abstraction, and easy to use.

    NSOperation

    Task (NSOperation) / pool+scheduler (NSOperationQueue) based interface which now uses libdispatch. This feels more task focused than libdispatch. It preceded libdispatch, and has an ObjC interface. There is, however, a lot of overlap in functionality. Rather fast and simple abstraction, and easy to use.

    Add an NSInvocation or ‘perform selector on thread’ to a run loop

    If your task is simple, you may want to use this low overhead approach of simply telling an object to perform a selector or an NSInvocation on a particular thread. The system will add it to the list of things to do (for the specified thread’s run loop).

    Having read your updates and comments and not knowing the time/complexity your specific problem, I’d suggest NSOperation. pthreads are pretty complex, and you should favor pooling over spawning threads whenever you need something to be performed asynchronously.

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

Sidebar

Related Questions

I tested this block of code and find that the GetInts method does not
HashSet does not have an AddRange method, so I want to write an extension
I want to re-write a method that has way too many nested if statements.
I want to write a C# method that can accept any number. Something like:
OK, I know what you're thinking, "why write a method you do not want
The setting: I want to write a point-to-point Connection class that, when used, does
Give a base class Base , I want to write a method Test, like
?string.Format(CultureInfo.GetCultureInfo(en-US), {0:d}, now) 4/12/2010 ?string.Format(CultureInfo.GetCultureInfo(fr-FR), {0:d}, now) 12/04/2010 I want to write a method:
I want to write a Swing application in Griffon but I am not sure
I want to write a command that specifies the word under the cursor in

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.