I have an application that has to perform a long action and while performing it, be able to react to pressing "Esc" and cancel that long operation. That "long action" is a series of Applescript calls. If i perform these calls in NSOperation's -main function the speed significantly decreases - i guess this is because of NSAppleScript's implementation that operates with main runloop. So, i decided to do the following - i will execute the "long action" in a main thread, and create an "Esc-listening thread" that will install a system-wide keyboard EventTap (which watches ESC presses, and if it gets any, it rises the cancellation flag - this flag is periodically checked in the main thread's "long alhorithm").
The thing i can't understand - is how to make that secondary thread to have a run loop, and how to make it not to finish as soon as i have created it - but to watch its own run loop for "event taps"'s events. Most tutorials are about putting "long operations" into the secondary thread, but what i am trying to achieve - is to put the "run loop" in it. How could it be done? P.S. i need a system wide hook, because the idea of the application is to react on keypresses in several applications, so this is the best idea for me Thanks! _______________________________________________ Cocoa-dev mailing list ([email protected]) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
