waitUntilDone: parameter when performing selector on main thread
waitUntilDone: parameter when performing selector on main thread
- Subject: waitUntilDone: parameter when performing selector on main thread
- From: Graham Cox <email@hidden>
- Date: Tue, 12 Nov 2013 15:26:37 +0100
I’m just thinking about the use of -performSelectorOnMainThread:withObject:waitUntilDone:, and what is the best way to think about the waitUntilDone parameter. The situation is updating a UI from another thread, using this to punt the update to the main thread (in fact the progress bar situation discussed earlier this week).
I assume if I pass NO, the request is queued and processed once per event loop. If I pass YES, there is some sort of lock which sleeps my thread until the main thread completes the task.
So passing NO, my worker thread can proceed as fast as it can, but the main thread could back up and end up lagging (and also queuing a lot of redundant updates, like a progress value where really only the latest matters). If I pass YES, my worker thread is going to get throttled by the main thread.
Is this just one of those cases where you have to judge the best approach, or is there a better way to determine when to pass YES or NO?
Currently, I generally pass NO, and my worker threads are not updating the progress too often anyway - I mod the count so that it only updates every 50 or 100 iterations. The UI seems to keep up fine. What do others do?
—Graham
_______________________________________________
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