Re: Animating a NSProgressIndicator
Re: Animating a NSProgressIndicator
- Subject: Re: Animating a NSProgressIndicator
- From: Fritz Anderson <email@hidden>
- Date: Mon, 13 Jun 2011 10:05:20 -0500
On 13 Jun 2011, at 9:48 AM, email@hidden wrote:
> But, the primary thing I would like to know is whether or not I can make the progress bar animate while the while(1){} loop is running inside of the drawRect: method of MyClass without using an additional window. While I wrote the infinite loop as while(1){}, which would allow me to insert my own code into the while loop and may allow the progress indicator to animate, in the real case, I do not have the ability to modify the code executing the long process.
Absolutely not. drawRect: is for drawing, not for computation. It is supposed to be as close to immediate as possible. Not only is it bad practice in isolation, but in some circumstances, the OS may require you to draw your view in more than one place. Bad.
Factor the long process out of drawRect:. For instance, put it into a separate thread, and have it send setNeedsDisplay to the view on the main thread. As a bonus, you can display a progress indicator that actually indicates progress on a task, and not as a proxy for the spinning inactivity cursor.
— F
_______________________________________________
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