예제 #1
0
        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);
                }
            }
        }
예제 #2
0
        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);
            }
        }