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

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

Reply via email to