• 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: NSProgressIndicator needs -display after -setDoubleValue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSProgressIndicator needs -display after -setDoubleValue
      • From: Jerry Krinock <email@hidden>
References: 
 >NSProgressIndicator needs -display after -setDoubleValue (From: Jerry Krinock <email@hidden>)

  • Prev by Date: [Q] HexInputServer not working?
  • Next by Date: Re: Using an NSMatrix subclass for a board game view
  • Previous by thread: Re: NSProgressIndicator needs -display after -setDoubleValue
  • Next by thread: Re: NSProgressIndicator needs -display after -setDoubleValue
  • Index(es):
    • Date
    • Thread