예제 #1
0
        public static void AnalyzeScreen(string success, IBaseFunction successAction, IBaseFunction failureAction, string[] prop, TFunction caller = null)
        {
            var tfunc = new TFunction(caller.Function, new List <EDefinition>(), string.Join(",", caller.Function.GetInvokeProperties()), caller.CallingFunction);

            try
            {
                bool   finished = false;
                bool   func     = false;
                Thread th       = new Thread(() =>
                {
                    AnalyzeScreen ascreen = new AnalyzeScreen();
                    ascreen.Analyze(success.UnCleanString(),
                                    () => { finished = true; func = true; },
                                    () => { finished = true; },
                                    prop
                                    );
                });
                th.Start();
                Stopwatch watch = new Stopwatch();
                watch.Start();
                while (finished == false)
                {
                    if (TokenParser.Stop)
                    {
                        break;
                    }
                    Thread.Sleep(1000); //sleep for 1 second before checking again
                                        //if 30 seconds go by, then break and kill the thread
                    if (watch.Elapsed.TotalMilliseconds >= 45000)
                    {
                        Compiler.ExceptionListener.ThrowSilent(new ExceptionHandler(ExceptionType.SystemException,
                                                                                    $"CheckScreen() timed out."));
                        //smash the thread and move on. we dont care about that data anyway
                        try { th.Abort(); } catch (Exception e) { if (!(e is ThreadAbortException))
                                                                  {
                                                                      throw;
                                                                  }
                        }
                        break;
                    }
                }
                watch.Stop();
                if (func)
                {
                    successAction.TryParse(tfunc);
                }
                else
                {
                    failureAction.TryParse(tfunc);
                }
            }
            catch
            {
                Compiler.ExceptionListener.ThrowSilent(new ExceptionHandler("[63]Image check failed to execute. Continuing with failure function"));
                failureAction.TryParse(tfunc);
            }
        }
예제 #2
0
        public override string[] Extend(IBaseFunction input)
        {
            List <string> temp = new List <string>();

            temp.Add(input.Name);
            temp.AddRange(base.Extend());
            FunctionReference.TryParse(new TFunction(FunctionReference, null, temp.ToArray(), null));
            return(Execute(FunctionReference.ReturnBubble.ToString()));
        }