Debugger2.CurrentThread 属性

获取或设置当前正在调试的线程。

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

语法

声明
Property CurrentThread As Thread
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)

属性值

类型:Thread
一个 Thread 对象。

示例

下面的示例演示如何使用 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 接口

EnvDTE80 命名空间