• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
waitUntilDone: parameter when performing selector on main thread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: waitUntilDone: parameter when performing selector on main thread
      • From: Quincey Morris <email@hidden>
    • Re: waitUntilDone: parameter when performing selector on main thread
      • From: Jens Alfke <email@hidden>
    • Re: waitUntilDone: parameter when performing selector on main thread
      • From: Roland King <email@hidden>
    • Re: waitUntilDone: parameter when performing selector on main thread
      • From: Jean-Daniel Dupas <email@hidden>
  • Prev by Date: Problems with reachability observer in Mavericks / Xcode 5
  • Next by Date: Re: Problems with reachability observer in Mavericks / Xcode 5
  • Previous by thread: Re: Problems with reachability observer in Mavericks / Xcode 5
  • Next by thread: Re: waitUntilDone: parameter when performing selector on main thread
  • Index(es):
    • Date
    • Thread