Re: NSProgressIndicator needs -display after -setDoubleValue
Re: NSProgressIndicator needs -display after -setDoubleValue
- Subject: Re: NSProgressIndicator needs -display after -setDoubleValue
- From: Adam Leonard <email@hidden>
- Date: Sat, 13 Oct 2007 00:17:56 -0700
-setUseThreadedAnimation: does exactly what it says it does. It makes
the progress bar's animation happen in a different thread (so, for
example the indeterminate spinner spins smoothly even when the main
thread is blocked).
It does not make messages you send to it run in another thread. So,
when you call -setDoubleValue:, it sends itself a setNeedsDisplay:
message, which will make the progress bar reflect the new value after
the main thread stops blocking.
Also, sending -setUseThreadedAnimation: many times does not generally
help :)
So, you are correct that when you block the main thread, you need to
send -display to get it to do its drawing immediately before it
returns.
There a couple solutions. First, if you can, put the loop code in a
separate thread or process so it does not block the main thread.
If you don't want to do that, you can always just call -
setDoubleValue and -display every n runs through the loop so it does
not need to redraw itself so many times. Be aware that the rest of
the application besides the progress bar's animation will still be
blocked, so the user may get a spinning beachball, and none of the
controls will work.
Adam Leonard
On Oct 12, 2007, at 9:10 PM, Jerry Krinock wrote:
Under normal circumstances; that is, in a small demo project, it is
not necessary to send any kind of 'display' message to an
NSProgressIndicator after updating the progress with -
setDoubleValue. It "just works". But in my real project, where my
progress indicator is programatically created and then added as a
subview to my custom NSControl, the progress stays stuck at 0
unless I send it a -display after each -setDoubleValue.
The progress is updated by a loop in a function in the main thread,
which blocks the main thread. Yes, I have told it to -
useThreadedAnimation:YES. Many times!! But it does not help.
Of course I don't want to leave -display in my loop, besides the
fact that it's bad engineering, it increases the run time of a
typical 2-second task up to about 10 seconds. And it only works
when I apply the heavyweight, -display. The nicer alternatives, -
setNeedsDisplay, and -setNeedsDisplay:YES, do not work.
I hope someone out there might know a tidbit about
NSProgressIndicator that might help me understand this.
Jerry Krinock
_______________________________________________
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:
40caffeinatedcocoa.com
This email sent to email@hidden
_______________________________________________
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