void Debugger_DebugCallbackEvent(DnDebugger dbg, DebugCallbackEventArgs e) { var ee = e as EvalDebugCallbackEventArgs; if (ee == null) { return; } if (ee.Eval == eval.RawObject) { debugger.DebugCallbackEvent -= Debugger_DebugCallbackEvent; e.AddStopReason(DebuggerStopReason.Eval); debugMessageDispatcher.CancelDispatchQueue(ee.WasException); return; } }
InvokeResult CallCore(MethodMirror method, Value?obj, IList <Value> arguments, FuncEvalOptions options, bool isNewobj) { if (evalTimedOut) { throw new TimeoutException(); } IInvokeAsyncResult?asyncRes = null; bool done = false; try { funcEvalState.isEvaluatingCounter++; var currTime = DateTime.UtcNow; var timeLeft = endTime - currTime; if (timeLeft >= TimeSpan.Zero) { funcEvalState.methodInvokeCounter++; Debug2.Assert(!isNewobj || obj is null); bool isInvokeInstanceMethod = obj is not null && !isNewobj; AsyncCallback asyncCallback = asyncRes2 => { if (done) { return; } InvokeResult resTmp; try { if (isInvokeInstanceMethod) { resTmp = obj !.EndInvokeMethodWithResult(asyncRes2); } else { resTmp = method.DeclaringType.EndInvokeMethodWithResult(asyncRes2); } debugMessageDispatcher.CancelDispatchQueue(resTmp); } catch (Exception ex) { debugMessageDispatcher.CancelDispatchQueue(ExceptionDispatchInfo.Capture(ex)); } }; if (isInvokeInstanceMethod) { asyncRes = obj !.BeginInvokeMethod(thread, method, arguments, GetInvokeOptions(options), asyncCallback, null); } else { asyncRes = method.DeclaringType.BeginInvokeMethod(thread, method, arguments, GetInvokeOptions(options), asyncCallback, null); } var res = debugMessageDispatcher.DispatchQueue(timeLeft, out bool timedOut); if (timedOut) { evalTimedOut = true; try { asyncRes.Abort(); } catch (CommandException ce) when(ce.ErrorCode == ErrorCode.ERR_NO_INVOCATION) { } throw new TimeoutException(); } if (res is ExceptionDispatchInfo exInfo) { exInfo.Throw(); } Debug.Assert(res is InvokeResult); return(res as InvokeResult ?? throw new InvalidOperationException()); } else { evalTimedOut = true; throw new TimeoutException(); } } finally { done = true; funcEvalState.isEvaluatingCounter--; asyncRes?.Dispose(); } }