Condividi tramite


Proprietà Debugger.CurrentThread

Ottiene o imposta il thread corrente sottoposto a debug.

Spazio dei nomi:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Sintassi

'Dichiarazione
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)

Valore proprietà

Tipo: EnvDTE.Thread
Oggetto Thread.

Note

La proprietà CurrentThread imposta o restituisce l'oggetto Thread correntemente sottoposto a debug.

Esempi

Nell'esempio seguente viene illustrato l'utilizzare della proprietà CurrentThread.

Per verificare la proprietà:

  1. Impostare un punto di interruzione nell'applicazione di destinazione. Eseguire il componente aggiuntivo.

    Il thread corrente è vuoto.

  2. Impostare un punto di interruzione nell'applicazione di destinazione. Eseguire l'applicazione di destinazione in modalità debug. Quando l'applicazione si interrompe al punto di interruzione, eseguire il componente aggiuntivo.

    Il thread corrente non è vuoto.

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

Sicurezza di .NET Framework

Vedere anche

Riferimenti

Debugger Interfaccia

Spazio dei nomi EnvDTE