Share via


Debugger.Stop Method

Stops debugging, terminating, or detaching from all attached processes.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.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, but you need to perform other tasks in the macro even before the debugger enters Design mode.

Remarks

Stop stops debugging and terminates the attached process. See How to: Stop Debugging or Stop Execution for more information.

Examples

The following example demonstrates how to use the Stop method.

To test this method:

  1. Set a breakpoint in the target application.

  2. Run the target application in Debug mode.

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

public static void Stop(DTE dte)
{
    EnvDTE.Debugger debugger = (EnvDTE.Debugger)dte.Debugger;
    debugger.Stop(true);
}
Shared Sub Stop(ByRef dte As EnvDTE.DTE)
    dte.Debugger. Stop(True)
End Sub

' WaitForDesignMode is true
Sub StopDebuggingAndNotifySync
    DTE.Debugger.Stop(True)
    MsgBox("Debugger has been stopped, for sure.")
End Sub

' WaitForDesignMode is false
Sub StopDebuggingAndNotifyAsync

    DTE.Debugger.Stop(False)

     ' Depending on how long it takes to stop debugging, 
     ' the environment may or may not yet be in Design mode.
    If DTE.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 integrated development environment (IDE) never has a chance to enter Design mode. Instead, you should resort to a separate thread or pooling mechanism.

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

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

    MsgBox("Debugger has been stopped")

End Sub

.NET Framework Security

See Also

Reference

Debugger Interface

EnvDTE Namespace