Re: Is it possible to set up an 'instant' idle handler
Re: Is it possible to set up an 'instant' idle handler
- Subject: Re: Is it possible to set up an 'instant' idle handler
- From: "Marc K. Myers" <email@hidden>
- Date: Mon, 7 Oct 2002 14:29:55 -0400
From: Sven Ryen <email@hidden>
Date: Mon Oct 7, 2002 12:44:13 PM America/Detroit
To: "Marc K. Myers" <email@hidden>
Subject: Re: Is it possible to set up an 'instant' idle handler
On 07.10.2002 01:24, "Marc K. Myers" <email@hidden> wrote:
Date: Mon, 07 Oct 2002 00:00:59 +0200
Subject: Is it possible to set up an 'instant' idle handler
From: Sven Ryen <email@hidden>
To: Greg Ray <email@hidden>
Hi!
I read in the documentation that the idle handler had to return an
integer
in order to schedule it to be re-run. Is it possible to make it run
'instantly', rather than wait for a second?
No. Why do you want to? If you want an action to repeat immediately
why not simply put it into a tight loop?
But won't that waste CPU resources when nothing is to be done?
The script will routinely check for items that are waiting to be
processed,
and a separate if-branch will kick in to carry out various tasks when
needed. If nothing is to be done, the plan was to have the script wait
a
while (though less than a second; more like tenth of a second), then
check
again to see if items have been added to the queue.
Can such a strategy be implemented without the use of an idle handler?
The script will be running indefinitely as a background application
(though
routinely restarts are likely to be carried out).
Cheers,
Sven Ryen
--
Phone. +47 6113 4486 - mob. +47 9979 8717 - <http://www.maxus.no/>
Someone (I think it was Paul Berkowitz) pointed out if you don't put in
a return statement an idle handler will repeat "instantly". I have
found through experimentation that this is not true. I constructed
this script for testing:
property startTime : missing value
property loopCnt : 0
on run
set loopCnt to 0
set startTime to (current date)
end run
on idle
set loopCnt to loopCnt + 1
if loopCnt > 999 then
tell me to activate
display dialog ((current date) - startTime) as text
tell me to quit
end if
end idle
The result was 1016 seconds, slightly more than a second per iteration.
I ran this on a 466MHz G4 machine under OS 10.2.1.
Yes, if you put your check in a tight loop it will waste system
resources but there is no provision for idle handlers to return on less
than a one second interval. If you really need to check at 0.1 second
intervals you may have to develop a conventional application.
Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074
[10/07/02 2:29:49 PM]
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.