Freigeben über


Thread2.Freeze-Methode

Beendet das Ausführen des Threads.

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

Syntax

'Declaration
Sub Freeze
void Freeze()
void Freeze()
abstract Freeze : unit -> unit
function Freeze()

Hinweise

Weitere Informationen finden Sie unter Gewusst wie: Verwenden des Threadfensters.

Beispiele

Das folgende Beispiel veranschaulicht die Verwendung der Freeze-Methode.

So testen Sie diese Methode

  1. Legen Sie den Haltepunkt in der Callbackmethode des Arbeitsthreads fest.

  2. Führen Sie die Zielanwendung im Debugmodus aus.

  3. Führen Sie das Add-In aus, wenn die Anwendung am Haltepunkt anhält.

public static void FreezeThawTest(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 Freeze Thaw 
      Test");
    owp.Activate();

    EnvDTE.Threads threads = dte.Debugger.CurrentProgram.Threads;
    owp.OutputString("There are " + threads.Count + " threads:\n");
    foreach(EnvDTE90.Thread2 thread in threads)
    {
        owp.OutputString("\nThread: " + thread.ID + "  Name: " + 
          thread.Name);
        owp.OutputString("\n  Is frozen                  : " + 
          thread.IsFrozen);
        owp.OutputString("\n  Freezing . . . ");
        thread.Freeze();
        owp.OutputString("\n  Is frozen                  : " + 
          thread.IsFrozen);
        owp.OutputString("\n  Thawing . . . ");
        thread.Thaw();
        owp.OutputString("\n  Is frozen                  : " + 
          thread.IsFrozen);
    }
}
Shared Sub FreezeThawTest(ByRef dte As EnvDTE80.DTE2)
    Dim str As String
    Dim threads As EnvDTE.Threads = dte.Debugger.CurrentProgram.Threads
    str = "There are " + threads.Count.ToString() + " threads running."
    For Each thread As EnvDTE90.Thread2 In threads
        str += vbCrLf + vbCrLf + "  Thread: " + thread.ID.ToString()
        str += vbCrLf + vbCrLf + "  Is frozen: " + _
          thread.IsFrozen.ToString()
        str += vbCrLf + vbCrLf + "  Freezing ... "
        thread.Freeze()
        str += vbCrLf + vbCrLf + "  Is frozen: " + _ 
          thread.IsFrozen.ToString()
        str += vbCrLf + vbCrLf + "  Thawing ... "
        thread.Thaw()
        str += vbCrLf + vbCrLf + "  Is frozen: " + _
          thread.IsFrozen.ToString()
    Next
    MessageBox.Show(str, "Thread Freeze Thaw Test")
End Sub

.NET Framework-Sicherheit

Siehe auch

Referenz

Thread2 Schnittstelle

EnvDTE90-Namespace

IsFrozen

Thaw

Weitere Ressourcen

Debuggen von Threads und Prozessen in Visual Studio

Diagramm "Automationsobjektmodell"

Gewusst wie: Verwenden des Threadfensters