• 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
Re: Multithreading question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multithreading question


  • Subject: Re: Multithreading question
  • From: Anthony Byrne <email@hidden>
  • Date: Thu, 17 Nov 2005 15:52:01 -0500

email@hidden wrote:

The processing thread is created by NSApplication's detachDrawingThread.

I experienced several UI glitches (text overlays, strange
NSProgressIndicator behaviour) and I found out that there was an issue with
threads.

Here are some possible solutions I gathered:

- Stop using bindings, manually update each view with code enclosed in if ([view
lockFocusIfCanDraw])...
- Stop using bindings, and perform all the UI updating in the main thread, using
a method called with performSelectorOnMainThread.
- Enclose all the model/controller code that could result in the modification
of a view by if ([view lockFocusIfCanDraw]), where view is the corresponding
view.
- In the processing thread, call all the model/controller methods with
performSelectorOnMainThread so that they will run in the main thread.


My understanding is that the AppKit is for the most part not thread-safe. I was not familiar with detachDrawingThread:toTarget:withObject but the doc leads me to believe that there's nothing special about it other than automatically creating an autorelease pool for you. Seems like the name could be a little misleading?

So I think one of your variations on performSelectorOnMainThread would be your best bet. I don't see any reason why that would prohibit using bindings, so most of your code could likely stay as it is.

If there's a more canonical approach, I too would be interested in hearing about it.

Regards,
Tony Byrne

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: text caret color
  • Next by Date: OT:XCode Plugins
  • Previous by thread: Re: Multithreading question
  • Next by thread: text caret color
  • Index(es):
    • Date
    • Thread