internal void DispatchEvent(ManagedCallbackType callback, CorEventArgs e) { try { if (m_callbackAttachedEvent != null) { m_callbackAttachedEvent.WaitOne(); // waits till callbacks are enabled } var d = m_callbacksArray[callback]; d(this, e); } catch (Exception ex) { CorExceptionInCallbackEventArgs e2 = new CorExceptionInCallbackEventArgs(e.Controller, ex); 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); var d = m_callbacksArray[ManagedCallbackType.OnExceptionInCallback]; d(this, e2); } catch (Exception ex2) { Debug.Assert(false, "Exception in Exception notification callback: " + ex2.ToString()); // ignore it -- there is nothing we can do. } e.Continue = e2.Continue; } }
internal void DispatchEvent(ManagedCallbackType callback, CorEventArgs e) { try { // CorProcess.Continue has an extra abstraction layer. // - The fist call just sets m_callbackAttachedEvent // - future calls go to ICorDebugProcess::Continue. // This ensures that we don't dispatch any callbacks until // after CorProcess.Continue() is called. 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) { CorExceptionInCallbackEventArgs e2 = new CorExceptionInCallbackEventArgs(e.Controller, ex); Debug.Assert(false, "Exception in callback: " + ex.ToString()); try { // we need to dispatch the exception 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) { Debug.Assert(false, "Exception in Exception notification callback: " + ex2.ToString()); // ignore it -- there is nothing we can do. } e.Continue = e2.Continue; } }
// 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; } }