Powered By Blogger

Thursday, February 16, 2012

Thread in Objective C

Here is the Idea about OperationQueue for Thread Management. Please read it carefully this will surely help you.
 NSOperationQueue *updateOrderStatusQueue;
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self
                                                                                        selector:@selector(MethodNameWhichYouWantToCallInThread)
                                                                                          object:nil];
                [operation setThreadPriority:NSOperationQueuePriorityNormal];
                [updateOrderStatusQueue addOperation:operation];
                [operation release];


updateOrderStatusQueue is the NSOperationQueue in which you can put multiple threads having different priority of task.

And using below you can also can all the operations in operation queue.

                if (updateOrderStatusQueue != nil) {
                    NSLog(@"Queue Operation Cancelled.");
                    [updateOrderStatusQueue cancelAllOperations];
                }

No comments:

Post a Comment