Udostępnij za pośrednictwem


Debugger.CurrentThread Property

Sets or gets the current thread being debugged.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Syntax

'Declaration
Property CurrentThread As Thread
'Usage
Dim instance As Debugger 
Dim value As Thread 

value = instance.CurrentThread

instance.CurrentThread = value
Thread CurrentThread { get; set; }
property Thread^ CurrentThread {
    Thread^ get ();
    void set (Thread^ value);
}
function get CurrentThread () : Thread 
function set CurrentThread (value : Thread)

Property Value

Type: EnvDTE.Thread
A Thread object.

Remarks

CurrentThread sets or returns the Thread object being currently debugged.

Examples

The following example demonstrates how to use the CurrentThread property.

To test this property:

  1. Set a breakpoint in the target application. Run the add-in.

    The current thread is empty.

  2. Set a breakpoint in the target application. Run the target application in the debug mode. When the application stops at the breakpoint, run the add-in.

    The current thread is not empty.

public static void CurrentThread(DTE dte)
{
    // Setup the 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: ");
    EnvDTE.Thread thread = dte.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);
}
Shared Sub CurrentThread(ByRef dte As EnvDTE.DTE)
    Dim str As String
    Dim thread As EnvDTE.Thread = dte.Debugger.CurrentThread
    If thread Is Nothing Then
        MessageBox.Show("No program is being debugged.", _
                        "Debugger Test - Current Thread Info")
    Else
        For Each sf As EnvDTE.StackFrame In thread.StackFrames
            str += vbCrLf + "Stack Frame: Function " + _
                   sf.FunctionName.ToString() + " returns type " + _
                   sf.ReturnType
        Next
        MessageBox.Show(str, "Debugger Test - Current Thread Info")
    End If
End Sub

.NET Framework Security

See Also

Reference

Debugger Interface

Debugger Members

EnvDTE Namespace