On Oct 18, 2008, at 7:27 PM, Andrew Merenbach wrote:

On Oct 18, 2008, at 4:23 AM, Peter Zegelin wrote:

Hi,

Still fairly new to Cocoa here.

I have a high priority thread that that for the moment just calls back as often as possible to a method that updates a static text object with the current time. A slider is also updated to a new value. Its a bit like a stop watch with a position indicator. This all works well until I resize a window or invoke a menu when the whole thing just grinds to a halt. If I call std::cout with the value the debugger shows a continuous stream of data so I know the thread is still being called as often as possible but the text and slider aren't updating. Is there any way to get these items to update under these circumstances? I tried calling [label setNeedsDisplay] but that just caused a crash.


thanks!

Peter Zegelin

Hi, Peter,

Is it possible that your GUI objects are being updated from the secondary thread? You'll need to use -performSelectorOnMainThread: to channel updates from the high-priority thread to the main thread, since only the main thread is allowed to touch the graphical AppKit classes (which are generally not threadsafe, with the possible exception of NSProgressIndicators). Hopefully this solves your issue!

Cheers,
        Andrew


Erm, sorry to respond to myself, but I was lazy -- just for clarity, the full methods available are (from the docs):

- (void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg waitUntilDone:(BOOL)wait; - (void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg waitUntilDone:(BOOL)wait modes:(NSArray *)array;

-- Andrew

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list ([email protected])

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

This email sent to [EMAIL PROTECTED]

Reply via email to