• 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
Threads and UI
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Threads and UI


  • Subject: Threads and UI
  • From: Daniel Todd Currie <email@hidden>
  • Date: Thu, 11 Dec 2003 00:37:51 -0800

Apologies for my previous post... (wrong list)

Everyone tells me that it is best to do all UI updating in the main thread. I have an NSBezierPath that I want to update every 0.01 seconds (achieving an animation). It seems very easy to me to just place the drawRect: method in a while loop and have it pause for 0.1 seconds in every loop. The only way to do this as far as I can tell is in a separate thread, since I wouldn't want to have the entire app pausing for 0.01 seconds while i animate this stupid line. Is this reasonable/safe?

Otherwise I could set up an NSTimer and call some sort of messenger method (since I can't call drawRect: with a timer directly), which seems like a bit of a kludge.

Aside from this specific question, can someone perhaps describe what is meant by "thread safety" and the potential risks of UI updates outside of the main thread?

TIA,

Daniel Currie
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Threads and UI
      • From: Chris Hanson <email@hidden>
    • Re: Threads and UI
      • From: Nick Zitzmann <email@hidden>
  • Prev by Date: Re: Polling Callback, Threads [Attn: Michael Thornburgh]
  • Next by Date: NSConnection on same machine between different users (via 10.3 fast switching)
  • Previous by thread: Re: Polling Callback, Threads [Attn: Michael Thornburgh]
  • Next by thread: Re: Threads and UI
  • Index(es):
    • Date
    • Thread