Debugger3.Stop 方法

停止调试,并终止所有附加的进程或从所有附加的进程分离出来。

命名空间:  EnvDTE90
程序集:  EnvDTE90(在 EnvDTE90.dll 中)

语法

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

参数

  • WaitForDesignMode
    类型:Boolean

    如果仅当调试会话进入设计模式时才应该停止该会话,则设置为 true。 如果打算停止调试,则设置为 false。 但是,在调试器进入设计模式之前,需要在宏中执行其他任务。

备注

有关详细信息,请参阅<PAVEOVER> 如何:停止调试或停止执行

示例

下面的示例演示如何使用 Stop 方法。

若要测试此方法,请执行下列操作:

  1. 在目标应用程序中设置一个断点。

  2. 以调试模式运行目标应用程序。

  3. 当此应用程序停在该断点处时,运行外接程序。

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

备注

宏在 Visual Studio 的主线程上运行。由于 IDE 始终不会进入设计模式,因此下面的代码无法运行,宏将陷入死循环。此时,应改用单独的线程或池机制。

' 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 安全性

请参阅

参考

Debugger3 接口

EnvDTE90 命名空间