示例#1
0
        public static List<BaseItem> ExecuteFunction(AhkContentSource source)
        {
            ExecuteFunctionAndWaitForResult(source);

            List<string> result = GetMessageFileContents();

            var items = new List<BaseItem>();

            DateTime timeStamp = DateTime.MaxValue;
            for (int i = 0; i < result.Count; i += 2)
            {
                if (i >= result.Count - 1)
                {
                    break;
                }

                timeStamp = timeStamp.AddTicks(-1);

                var executableItem = new ExecutableItem
                {
                    Name = result[i],
                    LastAccess = timeStamp
                };

                executableItem.Arguments.Add(new StringValue
                {
                    Value = result[i + 1]
                });

                items.Add(executableItem);
            }

            return items;
        }
示例#2
0
        private static void ExecuteFunctionAndWaitForResult(AhkContentSource source)
        {
            using (var waitHandle = new ManualResetEvent(false))
            {
                // ReSharper disable once AccessToDisposedClosure
                Action action = () => waitHandle.Set();

                var mainForm = FormFactory.Instance<MainForm>();

                try
                {
                    mainForm.AhkFunctionResultReported += action;
                    ExecuteMethod(source.ReturnType, source.Function, source.InteropArguments.ToArray());
                    waitHandle.WaitOne();
                }
                finally
                {
                    mainForm.AhkFunctionResultReported -= action;
                }
            }
        }