How can you lower the CPU usage of a script?

Some of the scripts I have ran seems to occupy alot of the CPU (20%). These are little scripts too. They make use of repeats and some delays. I know this can can cause the script/app to be difficult to shut down…sometimes they have to be forced quit. Can you reconmend:

  1. A way to have a script/app so it is always running/listening AND maintaining a low CPU usage?
  2. A way to have this constantly running script/app shut down easily?

I wrote a script that stays on all night, keeping my computer online downloading. The trick is called the IDLE handler.
During delay and repeat the script is at full steam, hogging all the processor, going over the same line of code.
An Idle handler runs every so often while your script is open, goes through the code once, and comes back to it in however long a time you specify.

on idle
do stuff
return 30
end idle

Times are in seconds. For example the code above reruns every thirty seconds. Increasing the time will lower processor load, since it doesn’t run as often. However, your program may be slow to respond to interactions with it that rely on idle code.

http://developer.apple.com/documentation/AppleScript/Conceptual/AppleScriptLangGuide/AppleScript.e7.html
http://www.applescriptsourcebook.com/tips/idlethoughts.html