Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Sporadic crash when using executeAndReturnError -> UseTerminology
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sporadic crash when using executeAndReturnError -> UseTerminology




On 17 Aug 2005, at 20:30, Christopher Nebel wrote:

On Aug 17, 2005, at 7:41 AM, Daniel Jalkut wrote:


As I understand it, the way to avoid the screeching halt is to install callback methods on OSA such that you get time to "feed your app" even while the script is running. I believe this is what application's like Script Editor do to maintain a responsive user interface while running.

One problem is that there doesn't seem to be a "one-stop shop" for getting time while a script is executing. There is the "action proc" which only gets called back while the script is literally running (its commands are being interpreted - not waiting for another applications to respond). Then there is the "AEIdle callback" which gets called at certain, difficult to predict (for me) times.

Adding to the confusion, you have to register callbacks for these two mechanisms in a completely different way (one is a simple callback on the scripting component, the other (the idle) you have to intercept all AppleEvent sends and tack your own idle proc onto it.

I hope I've drastically misunderstood things and there is a much simpler way to go about this. Unfortunately, I haven't heard anything yet. Often the workaround that gets suggested is simply to fork a separate process to handle the script. Multi-threading at its guaranteed best! I've resisted this so far but who knows ...

It would be great if somebody more knowledgeable than me had some wisdom to share about the "best way" to accomplish main-thread responsiveness while executing a script.


No, you've got it basically correct. AppleScript is not thread- safe; running it on a secondary pre-emptive thread will lead to suffering. The only solutions currently are to run it on the main thread and use the callbacks, use cooperative threads, or fork another process to run the script.

So I can't run it on a secondary thread even if I'm not doing anything applescripty in the main thread? That's what I'm doing here, and it seems to be working ok...but if you think it's going to cause problems in certain situations, I'll take your word for it and go & try figure out those callbacks...


Jon _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-implementors mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
References: 
 >Re: Sporadic crash when using executeAndReturnError -> UseTerminology (From: Bill Cheeseman <email@hidden>)
 >Re: Sporadic crash when using executeAndReturnError -> UseTerminology (From: Jonathan del Strother <email@hidden>)
 >Re: Sporadic crash when using executeAndReturnError -> UseTerminology (From: Daniel Jalkut <email@hidden>)
 >Re: Sporadic crash when using executeAndReturnError -> UseTerminology (From: Christopher Nebel <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.