Metodo Thread.Freeze

Arrestare il thread di eseguire.

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

Sintassi

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

Note

Per ulteriori informazioni, vedere Procedura: utilizzare la finestra Thread.

Esempi

Nell'esempio seguente viene illustrato come utilizzare Freeze metodo.

Per testare questo metodo

  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 FreezeThawTest(DTE 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(EnvDTE.Thread 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 EnvDTE.DTE)
    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 EnvDTE.Thread 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

Sicurezza di .NET Framework

Vedere anche

Riferimenti

Thread Interfaccia

Spazio dei nomi EnvDTE

Thaw