Re: while loop with sleep(): logging works, but not UI events
Re: while loop with sleep(): logging works, but not UI events
- Subject: Re: while loop with sleep(): logging works, but not UI events
- From: Daniel Richman <email@hidden>
- Date: Sat, 28 Jun 2008 08:14:10 -0700
One second seems to be accurate enough for my purposes, but I'll
investigate using 0.5 seconds.
Daniel
Shawn Erickson wrote:
On Sat, Jun 28, 2008 at 7:58 AM, Michael Ash <email@hidden> wrote:
On Sat, Jun 28, 2008 at 12:10 AM, Shawn Erickson <email@hidden> wrote:
Also you should fire your timer every
0.75 of seconds (or so) to ensure your UI update is consistent/smooth.
Firing every second may cause your timer to fire a little after 1
second later so your UI could skip from say 50s to 52s.
I do not recommend this, as using 0.75s will guarantee a jittery
update. Consider what happens when you start at 0 and round down to
figure out what to display. You'll display 0, then 0 again. Then
you'll display 1, at 1.5 seconds after start, then 2 and 3 each 0.75
seconds after the previous number. The cycle repeats with 4, which
displays 1.5 seconds after 3.
Actually I meant to type 0.5s which is what I use in my code for this
type of thing and you don't want to use the timer to track time but
the actual system clock... assuming you use a simple repeating timer.
Firing once every 1 second can cause you skip numbers as timer jitter
walks near to a second boundary based on wall clock time.... assuming
you use a simple repeating timer and don't round as you suggest.
If you reschedule a timer every time the prior timer fires you can use
a 1 second timer delay if you attempt to ensure that your current time
isn't close to a second boundary of the wall clock.
..or rounding can be used (depends on how you are calculating the time, etc.)
-Shawn
_______________________________________________
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
_______________________________________________
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