Debugger2.CurrentThread Property
Gets or sets the current thread being debugged.
Namespace: EnvDTE80
Assembly: EnvDTE80 (in EnvDTE80.dll)
Syntax
'Declaration
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)
Property Value
Type: EnvDTE.Thread
A Thread object.
Implements
Examples
The following example demonstrates how to use the CurrentThread property.
To test this property:
Set a breakpoint in the target application. Run the add-in.
The current thread is empty.
Set a breakpoint in the target application. Run the target application in the debug mode. When the program stops at the breakpoint, run the add-in.
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 Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.