public void Main() { Process process = Start(); Assert.IsTrue(process.IsManaged); Assert.IsTrue(process.MainThread.IsStopped); Thread thread = process.MainThread; AssertStopped(thread, "main", "X.Main()"); AssertExecute("next"); AssertStopped(thread, "main+1", "X.Main()"); EE.IExpression expr = Interpreter.ExpressionParser.Parse("a.Sleep ().Sleep ().Sleep ()"); Console.WriteLine("TEST: {0}", expr); EE.EvaluationFlags flags = EE.EvaluationFlags.NestedBreakStates; EE.AsyncResult async = expr.Evaluate(thread.CurrentFrame, flags, delegate(EE.EvaluationResult result, object data) { Console.WriteLine("EVALUATION DONE: {0} {1}", result, data); }); bool completed = async.AsyncWaitHandle.WaitOne(700); Console.WriteLine("ASYNC WAIT DONE: {0}", completed); async.Abort(); async.AsyncWaitHandle.WaitOne(); Console.WriteLine("EVALUATION DONE"); AssertExecute("continue"); AssertTargetExited(thread.Process); }
public EE.AsyncResult Evaluate(StackFrame frame, EE.EvaluationFlags flags, EE.EvaluationCallback callback) { AsyncResult async = new AsyncResult(this); ST.ThreadPool.QueueUserWorkItem(delegate { ScriptingContext context = new ScriptingContext(Parser.Interpreter); context.InterruptionHandler = async; context.CurrentFrame = frame; if ((flags & EE.EvaluationFlags.NestedBreakStates) != 0) { context.ScriptingFlags |= ScriptingFlags.NestedBreakStates; } object data; EE.EvaluationResult result = DoEvaluateWorker(context, out data); callback(result, data); async.WaitHandle.Set(); }); return(async); }