Debugger3.Stop Method

Stops debugging and terminates or detaches from all attached processes.

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

Syntax

'Declaration
Sub Stop ( _
    WaitForDesignMode As Boolean _
)
void Stop(
    bool WaitForDesignMode
)
void Stop(
    [InAttribute] bool WaitForDesignMode
)
abstract Stop : 
        WaitForDesignMode:bool -> unit
function Stop(
    WaitForDesignMode : boolean
)

Parameters

  • WaitForDesignMode
    Type: System.Boolean

    Set to true if the debugging session should stop only when it reaches Design mode. Set to false if you intend to stop debugging. However, you have to perform other tasks in the macro before the debugger enters design mode.

Remarks

For more information, see <PAVEOVER> How to: Stop Debugging or Stop Execution.

Examples

The following example shows how to use the Stop method.

To test this method:

  1. Set a breakpoint in the target application.

  2. Run the target application in the debug mode.

  3. When the application stops at the breakpoint, run the add-in.

public static void Stop(EnvDTE80.DTE2 dte)
{
    EnvDTE90.Debugger3 debugger = (EnvDTE90.Debugger3)dte.Debugger;
    debugger.Stop(false);
}
' WaitForDesignMode is true.
Sub StopDebuggingAndNotifySync
    DTE2.Debugger.Stop(True)
    MsgBox("Debugger has been stopped, for sure.")
End Sub

' WaitForDesignMode is false.
Sub StopDebuggingAndNotifyAsync
    DTE2.Debugger.Stop(False)
    ' Depending on how long it takes to stop debugging, 
    ' you may or may not yet be in Design mode.
    If DTE2.Debugger.CurrentMode <> dbgDebugMode.dbgDesignMode
        MsgBox("Debugger still stopping")
    Else
        MsgBox("Debugger has been stopped")
    End If
End Sub

Note

Macros are run on the main thread of Visual Studio. The following code does not work and the macro loops indefinitely because the IDE never has an opportunity to enter design mode. Instead, use a separate thread or pooling mechanism.

' Bad Code Example.
Sub StopDebuggingAndWaitForDesign
    DTE2.Debugger.Stop(False)

    While DTE2.Debugger.CurrentMode <> dbgDebugMode.dbgDesignMode
        System.Threading.Thread.Sleep(50)
    End While

    MsgBox("Debugger has been stopped")
End Sub

.NET Framework Security

See Also

Reference

Debugger3 Interface

EnvDTE90 Namespace