Skip navigation.
 
mlRe: How to Delay, Wait, Pause...
FROM : Jens Alfke
DATE : Sun May 25 18:53:13 2008

On 25 May '08, at 2:40 AM, Thomas Davie wrote:

> I hate to say this, but any form of delay here is the *wrong* way to 
> do this.  You already know you have a race condition, all you're 
> doing is making it so the race condition will work out in your favor 
> 99.99% of the time.  There are still exceptional cases where the OS 
> will be busy doing something and your 0.1 second sleep will not be 
> enough to sort it out.  Instead of doing this, do your threading 
> properly, and get your locking right.


This is correct advice when it comes to interactions between multiple 
threads; but Steve's problem involves only a single thread. The timing 
here is measured in iterations of the thread's runloop, not in clock 
time. As Dmitri put it:

> From 10.4 on fetch: results are delayed until the next iteration of 
> the run loop


So I believe that any technique that cranks the runloop through at 
least one iteration will solve the problem, and that includes any sort 
of timer or perform-after-delay. (I often use performAfterDelay: 0.0, 
though it looks nonsensical on first glance, to delay some action 
until the very next runloop iteration.)

—Jens

Related mailsAuthorDate
mlHow to Delay, Wait, Pause... Steve Steinitz May 25, 08:45
mlRe: How to Delay, Wait, Pause... Peter Burtis May 25, 08:55
mlRe: How to Delay, Wait, Pause... Jens Alfke May 25, 09:05
mlRe: How to Delay, Wait, Pause... Michael Vannorsdel May 25, 09:07
mlRe: How to Delay, Wait, Pause... stephen joseph but… May 25, 09:31
mlRe: How to Delay, Wait, Pause... Steve Steinitz May 25, 11:22
mlRe: How to Delay, Wait, Pause... Thomas Davie May 25, 11:40
mlRe: How to Delay, Wait, Pause... Ken Thomases May 25, 11:49
mlRe: How to Delay, Wait, Pause... Michael Vannorsdel May 25, 12:00
mlRe: How to Delay, Wait, Pause... Dmitri Goutnik May 25, 12:23
mlRe: How to Delay, Wait, Pause... Steve Steinitz May 25, 13:34
mlRe: How to Delay, Wait, Pause... Steve Steinitz May 25, 13:36
mlRe: How to Delay, Wait, Pause... Steve Steinitz May 25, 13:46
mlRe: How to Delay, Wait, Pause... Jens Alfke May 25, 18:53
mlRe: How to Delay, Wait, Pause... Steve Steinitz May 26, 00:14