Share via


Debugger2.CurrentThread 屬性

取得或設定目前正在偵錯的執行緒。

命名空間:  EnvDTE80
組件:  EnvDTE80 (在 EnvDTE80.dll 中)

語法

'宣告
Property CurrentThread As Thread
    Get
    Set
Thread CurrentThread { get; set; }
property Thread^ CurrentThread {
    Thread^ get ();
    void set (Thread^ value);
}
abstract CurrentThread : Thread with get, set
function get CurrentThread () : Thread
function set CurrentThread (value : Thread)

屬性值

型別:EnvDTE.Thread
Thread 物件。

實作

Debugger.CurrentThread

範例

下列範例示範如何使用 CurrentThread 屬性。

若要測試這個屬性:

  1. 在目標應用程式中設定中斷點。 執行增益集。

    目前的執行緒是空的。

  2. 在目標應用程式中設定中斷點。 在偵錯模式執行目標應用程式。 當程式在中斷點上停止時,請執行增益集。

public static void CurrentThread(EnvDTE80.DTE2 dte)
{
    // Setup debug Output window.
    Window w = 
    (Window)dte.Windows.Item(EnvDTE.Constants.vsWindowKindOutput);
    w.Visible = true;
    OutputWindow ow = (OutputWindow)w.Object;
    OutputWindowPane owp = ow.OutputWindowPanes.Add("Current Thread 
    Test");
    owp.Activate();

    owp.OutputString("Current Thread Info: ");
    EnvDTE80.Debugger2 debugger = (EnvDTE80.Debugger2)dte.Debugger;
    EnvDTE.Thread thread = debugger.CurrentThread;

    if (thread == null)
        owp.OutputString("No program is being debugged");
    else
        foreach (EnvDTE.StackFrame sf in thread.StackFrames)
            owp.OutputString("\nStack Frame: Function " + sf.FunctionName +
                             " returns type " + sf.ReturnType);
}
Sub ShowCurrentProcess()
    ' This function displays the current debugger
    ' mode in the Output window.
    Dim ow As OutputWindow
    ow = DTE2.Windows.Item(Constants.vsWindowKindOutput).Object

    Dim proc As EnvDTE.Process2
    proc = DTE2.Debugger.CurrentProcess

    If (proc Is Nothing) Then
        ow.ActivePane.OutputString("No process is being debugged")
    Else
        ow.ActivePane.OutputString("" + Str(proc.ProcessID) + ": " + _
        poc.Name + vbCrLf)
    End If
End Sub

.NET Framework 安全性

請參閱

參考

Debugger2 介面

CurrentThread 多載

EnvDTE80 命名空間