Orange Peel
Orange Peel

Reputation: 484

Exit infinite loop by quitting application

I have an AppleScript application in which I have a background task running in an infinite loop.

repeat while true
    -- do some tasks
    delay 0.5
end repeat

When I export and run the application, I am not able to quit it normally, instead I have to use the force quit. How am I able to fix this?

Upvotes: 1

Views: 582

Answers (1)

vadian
vadian

Reputation: 285069

Instead of the infinite loop implement the on idle handler. It allows to consider the quit command.

on idle
    -- do some tasks
    return 1
end idle

However there is a restriction. The minimum interval is one second.

Upvotes: 3

Related Questions