Re: Choosing files
Re: Choosing files
- Subject: Re: Choosing files
- From: Shane Stanley <email@hidden>
- Date: Sat, 15 Nov 2014 10:27:07 +1100
On 14 Nov 2014, at 12:52 pm, Shane Stanley <email@hidden> wrote:
Before you run the following code, a warning: ASObjC code that involves drawing stuff on screen, like this, has to be run in the foreground on what is known as the main thread. Scripts are nearly always run on the main thread -- the one exception being in script editors, where they are usually run on background threads. So when you are trying out this code, if you don't run it in the foreground, you will crash your editor.
But when you're testing code, it's easy to forget. To be safe, you can insert the following snippet after the use statements:
if not (current application's NSThread's isMainThread()) as boolean then display alert "This script must be run from the main thread." buttons {"Cancel"} as critical error number -128 end if
Then if you accidentally run on a background thread, you will get an alert instead of a potential crash.
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden