Ken Thomases wrote:

[quote]
Note that if you don't make your operation "concurrent" in this
sense, but you queue it in an NSOperationQueue, that queue will still
run it asynchronously, in its own thread, concurrently with other
operations.  It's just that, for non-"concurrent" operations,
NSOperationQueue knows it has to manage the execution context itself
(by spinning off a thread)
[end quote]

I must be doing something terribly wrong, because when I start up the NSOperationQueue that does some time consuming calculations, I do not get back control of my application until after the lengthy calculation is complete. Here are the relevant code snippets:

- (void) calculateWorksheetRow:(id)data {
     // takes a long time here
}


- (void) startQueue {
        theQueue = [[[NSOperationQueue alloc] init] autorelease];
        theOp = [[NSInvocationOperation alloc] initWithTarget:self
selector:@selector(calculateWorksheetRow:)
                                               object:nil];
        [theQueue addOperation:theOp];
}


- (void) stopQueue {
        [theQueue cancelAllOperations];
        
     // [theQueue release];   // [ ... autorelease]
        [theOp release];
}


- (void) startCalculation {             
        int row;
        
        for (row=1; row < 100; row++) {
             // stuff here
                [self startQueue];   // start new thread
             // [theQueue waitUntilAllOperationsAreFinished];
        }
        
        // more stuff
}



John Love
Touch the Future! Teach!



_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to