Debugger.Stop 方法

停止偵錯、結束,或是從所有附加的處理序中斷連結。

命名空間:  EnvDTE
組件:  EnvDTE (在 EnvDTE.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
    型別:System.Boolean
    如果偵錯工作階段應只在進入設計模式時停止,請設定為 true。如果想要停止偵錯,但需要在甚至是偵錯工具進入設計模式前進行巨集中的其他工作,請設定為 false。

備註

Stop 會停止偵錯並結束附加的處理序。 如需詳細資訊,請參閱HOW TO:停止偵錯或停止執行

範例

下列範例示範如何使用 Stop 方法。

若要測試這個方法:

  1. 在目標應用程式中設定中斷點。

  2. 在偵錯模式執行目標應用程式。

  3. 當應用程式在中斷點停止時,請執行增益集。

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
注意事項注意事項

巨集執行於 Visual Studio 的主要執行緒中。 下列程式碼無法運作,巨集進行無限迴圈,因為整合式開發環境 (IDE) 永遠無法進入設計模式。 反之,您應該尋求不同的執行緒或共用機制。

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

請參閱

參考

Debugger 介面

EnvDTE 命名空間