Partilhar via


Debugger2.Stop(Boolean) Method

Definition

Stops debugging and terminates or detaches from all attached processes.

void Stop(bool WaitForDesignMode = true);
[System.Runtime.InteropServices.DispId(8)]
public void Stop (bool WaitForDesignMode = true);
[<System.Runtime.InteropServices.DispId(8)>]
abstract member Stop : bool -> unit
Public Sub Stop (Optional WaitForDesignMode As Boolean = true)

Parameters

WaitForDesignMode
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.

Implements

Attributes

Examples

The following example demonstrates how to use the Stop method.

public static void Stop(EnvDTE80.DTE2 dte)  
{  
    EnvDTE80.Debugger2 debugger = (EnvDTE80.Debugger2)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 a chance to enter design mode. Instead, resort to 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  

Remarks

See How to: Stop Execution for more information.

Applies to