• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSInvocationOperations and background Threads
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSInvocationOperations and background Threads


  • Subject: NSInvocationOperations and background Threads
  • From: John Love <email@hidden>
  • Date: Fri, 16 Oct 2009 09:01:46 -0400

NSOperation.pdf states:

"For a non-concurrent operation, an operation queue automatically creates a thread and calls the operation object’s start method, the default implementation of which configures the thread environment and calls the operation object’s main method to run your custom code."

In my app, I have a very long for-loop, each time thru which, I call NSInvocationOperation's -initWithTarget:selector:object:, followed by a call to add the resulting Operation to the NSOperationQueue. This queue is previously created via itsQueue = [[NSOperationQueue alloc] init], itsQueue being a instance variable.

I do not have a custom -start or a -main method, so I count on the default -start and -main methods to handle the creation of a background Thread for me. It appears however, that in my app there is no background Thread that begins and the reason for that is because my app's window stays in the background until all NSOperations are complete. Any clues?

By the way, when I alternately use either +detachNewThreadSelector or NSMachPorts, everything works just fine, including the app's window coming to the foreground, which event I force via [NSApp activateIgnoringOtherApps:YES] even before I start the background Thread.

One last question .. if a new background Thread is automatically started when I add the new NSInvocationOperation to the NSOperationQueue, is there a NSAutoreleasePool automatically created before the above selector method starts and is this NSAutoreleasePool released after this method finishes?

John Love
Touch the Future! Teach!



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSInvocationOperations and background Threads
      • From: Ken Thomases <email@hidden>
    • Re: NSInvocationOperations and background Threads
      • From: Nick Zitzmann <email@hidden>
  • Prev by Date: Re: Toolbar with capsule style items (Similiar to Mail)
  • Next by Date: Re: NSURLConnection timeout -- what happens?
  • Previous by thread: Re: Programming Style: Method Definition with or without a semicolon.
  • Next by thread: Re: NSInvocationOperations and background Threads
  • Index(es):
    • Date
    • Thread