Re: Problem with NSText:setString

"Diez B. Roggisch" <[email protected]>
Newsgroups gmane.comp.python.pyobjc.devel
Message-ID <[email protected]>
On Jun 13, 2011, at 2:07 PM, Daniel Luis dos Santos wrote:

> Hello,
> 
> I have a GUI application built with interface builder. One of the windows has a NSTextView in it. I connected it to an object also referenced in the interface builder file.
> The goal is to write to the NSTextView from a background trhead that does some task. I launch the thread with a call to 
> 
> 	NSThread.alloc().initWithTarget_selector_object_()
> 
> The behaviour I am getting is erratic. Most times it blocks on the call to the NSTextView's setString_() method and the application hangs. If I run the code on the main thread it runs fine.
> 
> How do I do this from a background thread ? The idea is to keep the application responsive.
> 
GUI and multi-theading = bad idea.

The main or GUI-thread is very sensitive about state being changed from other threads while it does it's works.

So usually there are ways to remedy this by special events that get pushed into the GUI-threads event-queue, or similar means.

The documentation relevant for this should be

 http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Multithreading/RunLoopManagement/RunLoopManagement.html#//apple_ref/doc/uid/10000057i-CH16-SW44


That should get you started.

Diez

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev

_______________________________________________
Pyobjc-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyobjc-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.