Ken ..

Thanks for your prompt reply, I really appreciate it.

I have revamped my code to have just one NSInvocationOperation whose selector contains the long for-loop. A snippet looks like:

        itsOps = [[NSInvocationOperation alloc] initWithTarget:self
selector:@selector(doAllOperations) /* data passed to selector */
                                                               object:nil];
[itsQueue addOperation:itsOps]; // itsQueue previously set = [[NSOperationQueue alloc] init]

and the long for-loop is within -doAllOperations. It's my understanding from the docs and other Cocoa mailing list readers that when -addOperation: is called, a new background Thread is started up. If that is true, then my long for-loop should be executing in the background Thread. If I'm still on-track, then I have a problem in that I temporarily placed a NSLog() call within my -doCalculation, but nothing gets printed in my log. So, for the moment I am lost.

By the way, delving into NSOperations is for the moment just an attempt to learn more since I have successfully called - detachNewThreadSelector, as well as delved into NSMachPorts and NSPortMessages with success. So, I'm just trying to learn a little bit more here.

Again, thanks.

John

=======

On Oct 17, 09, at 10:20 PM, Ken Thomases wrote:

On Oct 16, 2009, at 8:01 AM, John Love wrote:

In my app, I have a very long for-loop

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?

I suspect your app's window isn't staying in the background until all NSOperations are complete, but rather that it's staying in the background until your long for-loop completes.

You can't run a long for-loop on the main thread and expect event handling to proceed. (Well, you can, but only if your for-loop is handling events manually, itself.)

It sounds like you're fundamentally misunderstanding how things like the main run loop, event processing, operation queues, your for- loop, etc. interact.

Regards,
Ken


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to