Quandary : NSAppleScript ties up main thread
Quandary : NSAppleScript ties up main thread
- Subject: Quandary : NSAppleScript ties up main thread
- From: Jerry Krinock <email@hidden>
- Date: Mon, 10 Oct 2011 16:41:02 -0700
I currently run AppleScripts using -[NSAppleScript executeAndReturnError:]. Sometimes, but not often, one of them takes 5-10 seconds to execute, and when this happens I'd like to display a small window showing indeterminate progress.
However, any invocation to NSAppleScript must occur on the main thread, so the main thread is going to be blocked while it is running. I can run my 1-second timer on a secondary thread, but to display a window or even un-hide a progress bar in an existing window, I need the main thread. (Correct?) Thus, this ain't going to work.
NSAppleScript does not seem to have any asychronous/callback methods for executing scripts. The only solution I can think of is to not use it. Instead, maybe launch the script as an application, and return the result by writing it to a temp file which I'm observing with a kqueue, or some other form of interprocess communication. I don't think AppleScripts can talk to Mach ports.
Any suggestions to make this simple little enhancement less painful?
Thanks,
Jerry Krinock
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden