简体   繁体   中英

Problem about using NSOperationQueue and NSOperation in iphone OS

Im using NSOperation to do a task: download some files with NSURLConnection and then merge files that spend much cpu and memory
I need to excute the task in new/background thread
So I add some these tasks to NSOperationQueue and set maxConcurrentOperationCount = 2
But the result is when merging files it will block the main thread(UI not respond for a while) ,it seems not excuting in new/background thread
how to make it go as I expected ?

Since you using NSOperationqueue,therefore you are having only two files at one time and you can merge only them because all the other threads or files are not present there.

So for merging them together you will have to keep them together at one time.

What type of operations are you putting in the NSOperationQueue? Apple's documentation for the NSOperationQueue includes this note:

Note: In iOS, operation queues do not use Grand Central Dispatch to execute operations. They create separate threads for non-concurrent operations and launch concurrent operations from the current thread. For a discussion of the difference between concurrent and non-concurrent operations and how they are executed, see NSOperation Class Reference.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM