private void ExceptionInCallbackEventHandler(Object sender, CorExceptionInCallbackEventArgs e) { OriginalMDbgMessages.WriteLine("CorProcess::ExceptionInCallback"); e.Continue = false; m_stopReason = new MDbgErrorStopReason(e.ExceptionThrown); ++m_stopCount; m_stopCounter = g_stopCounter++; m_stopEvent.Set(); }
// when process is first created wait till callbacks are enabled. internal void DispatchEvent(ManagedCallbackType callback, CorEventArgs e) { try { if (m_callbackAttachedEvent != null) m_callbackAttachedEvent.WaitOne(); // waits till callbacks are enabled Debug.Assert((int) callback >= 0 && (int) callback < m_callbacksArray.Length); Delegate d = m_callbacksArray[(int) callback]; if (d != null) d.DynamicInvoke(new Object[] {this, e}); } catch (Exception ex) { var e2 = new CorExceptionInCallbackEventArgs(e.Controller, ex); OriginalMDbgMessages.WriteLine("Exception in callback: " + ex); // DC Debug.Assert(false,"Exception in callback: "+ex.ToString()); try { // we need to dispatch the exceptin in callback error, but we cannot // use DispatchEvent since throwing exception in ExceptionInCallback // would lead to infinite recursion. Debug.Assert(m_callbackAttachedEvent == null); Delegate d = m_callbacksArray[(int) ManagedCallbackType.OnExceptionInCallback]; if (d != null) d.DynamicInvoke(new Object[] {this, e2}); } catch (Exception ex2) { OriginalMDbgMessages.WriteLine("Exception in Exception notification callback: " + ex2); // DC Debug.Assert(false,"Exception in Exception notification callback: "+ex2.ToString()); // ignore it -- there is nothing we can do. } e.Continue = e2.Continue; } }