Proprietà Thread2.IsAlive

Indica se il thread a cui si fa riferimento è ancora attivo.

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

Sintassi

'Dichiarazione
ReadOnly Property IsAlive As Boolean
bool IsAlive { get; }
property bool IsAlive {
    bool get ();
}
abstract IsAlive : bool
function get IsAlive () : boolean

Valore proprietà

Tipo: System.Boolean
Un valore booleano.

Note

Restituiscetrue se il thread a cui si fa riferimento è ancora attivo; in caso contrario false.

[!NOTA]

Lo stato del thread può cambiare prima che la funzione restituisce.

Esempi

Nell'esempio seguente viene illustrato come utilizzare Collection proprietà.

Per verificare questa proprietà:

  1. Impostare il punto di interruzione nel metodo di callback del thread di lavoro.

  2. Eseguire l'applicazione di destinazione in modalità di debug.

  3. Quando l'applicazione si interrompe sul punto di interruzione, eseguire il componente aggiuntivo.

public static void TestThreadProperties(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("Thread Test");
    owp.Activate();

    EnvDTE.Threads threads = dte.Debugger.CurrentProgram.Threads;
    owp.OutputString("\nNumber of items in the Thread collection: " + 
      threads.Item(1).Collection.Count + "\n");
    foreach(EnvDTE90.Thread2 thread in threads)
    {
        owp.OutputString("\nThread: " + thread.ID + "  Name: " + 
          thread.Name);
        owp.OutputString("\n  Edition of the environment : " + 
          thread.DTE.Edition);
        owp.OutputString("\n  Is alive                   : " + 
          thread.IsAlive);
        owp.OutputString("\n  Is frozen                  : " + 
          thread.IsFrozen);
        owp.OutputString("\n  Location                   : " + 
          thread.Location);
        owp.OutputString("\n  Parent's current mode      : " + 
          thread.Parent.CurrentMode);
        owp.OutputString("\n  Priority                   : " + 
          thread.Priority);
        owp.OutputString("\n  Program name               : " + 
          thread.Program.Name);
        owp.OutputString("\n  Number of stack frames     : " + 
          thread.StackFrames.Count);
        owp.OutputString("\n  Suspended number of times  : " + 
          thread.SuspendCount);
        owp.OutputString("\n  Flag on the thread  : " + thread.Flag);
    }
}
Shared Sub ThreadProperties(ByRef dte As EnvDTE80.DTE2)
    Dim str As String
    Dim threads As EnvDTE.Threads = dte.Debugger.CurrentProgram.Threads
    str = "Number of items in the Thread collection: " + _
      threads.Item(1).Collection.Count.ToString()
    For Each thread As EnvDTE90.Thread2 In threads
        str += vbCrLf + vbCrLf + "  Thread: " + thread.ID.ToString()
        str += vbCrLf + "    Edition of the environment: " + 
          thread.DTE.Edition
        str += vbCrLf + "    Is alive: " + thread.IsAlive.ToString()
        str += vbCrLf + "    Is frozen: " + thread.IsFrozen.ToString()
        str += vbCrLf + "    Location: " + thread.Location
        str += vbCrLf + "    Parent's current mode: " + _
               thread.Parent.CurrentMode.ToString()
        str += vbCrLf + "    Priority: " + thread.Priority
        str += vbCrLf + "    Program name: " + thread.Program.Name
        str += vbCrLf + "    Number of stack frames: " + _
               thread.StackFrames.Count.ToString()
        str += vbCrLf + "    Suspended number of times: " + _
               thread.SuspendCount.ToString()
        str += vbCrLf + "    Flag on the thread: " + _
               thread.Flag.ToString()
    Next
    MessageBox.Show(str, "Thread Test - Properties")
End Sub

Sicurezza di .NET Framework

Vedere anche

Riferimenti

Thread2 Interfaccia

Overload IsAlive

Spazio dei nomi EnvDTE90

Altre risorse

Utilizzo di thread e processi

Grafico del modello a oggetti di automazione

Procedura: utilizzare la finestra Thread