Threaded Access to Display Elements
Threaded Access to Display Elements
- Subject: Threaded Access to Display Elements
- From: Chris Williams <email@hidden>
- Date: Sun, 23 Sep 2007 13:56:27 -0700
- Thread-topic: Threaded Access to Display Elements
I'm struggling with some display problems in my multi-threaded application.
I have a status bar and a progress bar in the bottom of my app's window.
The status field (an NSTextField) is always there, updated as the user
changes the active selection, or when a long operation is completed to
report the status. The progress bar is hidden, only present when they do
some lengthy operation.
The lengthy operations are done in a separate thread, of course. This works
fine, except with respect the to the updates to these two interface
elements. Updates to these fields is rather random. It works perfectly
sometimes, and is all messed up at others. Of course, if I do the
operations synchronously, all is well.
For example, occasionally the status field is all overdrawn (e.g. the old
text is still there, the new text scribbles all over it, making a mess).
Not always, just some times. The one that is driving me most nuts is the
progress indicator. It works, updates correctly, but I want it to hide when
the operation is complete. I "setHidden" and then do a "display" on the
progress bar, in the worker thread when it is done. Sometimes it works,
other times it doesn't, the progress bar remains on the screen.
Clearly I have conflicts with these controls because of the threaded nature.
And so, my question is, what is the best way to handle this kind of
interaction, to be sure the controls are properly updated from down in a
worker thread?
Thanks,
Chris
_______________________________________________
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