• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Quandary : NSAppleScript ties up main thread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Quandary : NSAppleScript ties up main thread
      • From: Shane Stanley <email@hidden>
    • Re: Quandary : NSAppleScript ties up main thread
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: Keeping grayscale image grayscale
  • Next by Date: drawRect not being called by NSCollectionView..
  • Previous by thread: Re: Keeping grayscale image grayscale
  • Next by thread: Re: Quandary : NSAppleScript ties up main thread
  • Index(es):
    • Date
    • Thread