repeating events with time delay

I know this is a common question, but how do you make a subroutine repeat, say, every minute?


Just attach the ‘idle’ handler to your application object and put your call to the subroutine in it. The following displays a dialog every 30 seconds. You can’t quit an idle handler once you start one, but you can set it it’s firing delay to a large amount of time. Idle handlers also don’t take up ‘too much’ cpu load.

on idle theObject
	return 30
end idle

to doSomething()
	display dialog "Did something!"
end doSomething


i tried that and it works except for the fact that my application now will sometimes refuse to quit. you press quit and nothing happens, but this only occurs about 1 out of 3 times. what did i do wrong?