private static void ProcessRequests(object sender) { while (true) { Tuple request = GetRequest(); AEDesc sourceData = new AEDesc(); string result; try { //apparently UnicodeText doesn't work AppleEvent.AECreateDescAscii(request.Request, out sourceData); result = Run(true, ref sourceData); if (request.Callback != null) { request.Callback.Invoke(result, null); } } catch (Exception ex) { if (request.Callback != null) { request.Callback.Invoke(null, ex); } } finally { AppleEvent.AEDisposeDesc(ref sourceData); } } }
public static string Run(string scriptSource) { AEDesc sourceData = new AEDesc(); try { //apparently UnicodeText doesn't work AppleEvent.AECreateDescAscii(scriptSource, out sourceData); return(Run(true, ref sourceData)); } finally { AppleEvent.AEDisposeDesc(ref sourceData); } }