Re: AppleScript waits until the application returns a result
Re: AppleScript waits until the application returns a result
- Subject: Re: AppleScript waits until the application returns a result
- From: Christopher Nebel <email@hidden>
- Date: Fri, 30 Nov 2001 12:29:49 -0800
On Friday, November 30, 2001, at 07:48 AM, Anderson, Bob wrote:
I can think of a very good reason for an application to return
immediately from a command. One application we wrote would take 10
minutes or more to complete a Apple event.
We did not want to set the timeout to an enormous value to compensate:
should the application hang up, the script and the whole machine would
be hung.
So we had our application return immediately and provided an Apple
event to return the busy status. The AppleScript program would then
use an idle handler to poll the program to check for completion.
Good motive, not so good solution. The problem with always handling an
event asynchronously is that (1) it's inconsistent with how AppleScript
normally works, so it tends to confuse folks, and (2) people who don't
mind just waiting don't have an easy solution. (The problem is
compounded when it's not documented that a command always returns
immediately!)
A better way to handle this would have been to either tell people to use
"ignoring application responses" or add an optional "handling in
background" parameter to the relevant command. You'd still have the
status command in either case.
--Chris Nebel
AppleScript Engineering
P.S.: I'm not sure why you say the entire machine would have hung if the
application did; even synchronous events won't wedge the system. (Sure,
the script itself isn't doing much, but even so you should be able to at
least hit command-period.)