Compartir a través de


DebuggerEventsClass.OnContextChanged Event

This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.

Fired whenever the current process, program, thread, or stack has been changed through the user interface or through the automation model.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Syntax

'Declaration
Public Overridable Event OnContextChanged As _dispDebuggerEvents_OnContextChangedEventHandler
public virtual event _dispDebuggerEvents_OnContextChangedEventHandler OnContextChanged
public:
virtual   event _dispDebuggerEvents_OnContextChangedEventHandler^ OnContextChanged {
    void add (_dispDebuggerEvents_OnContextChangedEventHandler^ value);
    void remove (_dispDebuggerEvents_OnContextChangedEventHandler^ value);
}
abstract OnContextChanged : IEvent<_dispDebuggerEvents_OnContextChangedEventHandler,
    EventArgs>
override OnContextChanged : IEvent<_dispDebuggerEvents_OnContextChangedEventHandler,
    EventArgs>
JScript does not support events.

Implements

_dispDebuggerEvents_Event.OnContextChanged

Examples

The following example demonstrates how to use the OnContextChanged event.

To test this event:

  1. Open the target application.

  2. Run the add-in.

    Observe the message box: "Events are attached."

  3. Set a breakpoint and run the target application in the debug mode.

  4. When the application stops at the breakpoint, stop the debugger.

    Observe the message box: "Debugger enters context changed mode."

// Place the following code in the Exec method of the add-in:
EnvDTE.DebuggerEvents debugEvents = applicationObject.Events.DebuggerEvents;
debugEvents.OnContextChanged += 
new _dispDebuggerEvents_OnContextChangedEventHandler(DebuggerEvents.ContextHandler);

// Place the following Event handler code in the add-in:
// Needed to activate event handlers in Connect.Exec.
public static void StartEvents(DTE dte)
{
    System.Windows.Forms.MessageBox.Show("Events are attached.");
}

public static void ContextHandler(EnvDTE.Process newProc, 
    EnvDTE.Program newProg, EnvDTE.Thread newThread, EnvDTE.StackFrame newStkFrame)
{
    System.Windows.Forms.MessageBox.Show("Debugger enters context changed mode.");
}

.NET Framework Security

See Also

Reference

DebuggerEventsClass Class

EnvDTE Namespace