共用方式為


Thread2.Freeze 方法

停止執行緒的執行。

命名空間:  EnvDTE90
組件:  EnvDTE90 (在 EnvDTE90.dll 中)

語法

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

實作

Thread.Freeze()

備註

如需詳細資訊,請參閱HOW TO:使用執行緒視窗

範例

下列範例示範如何使用 Freeze 方法。

若要測試這個方法:

  1. 在背景工作執行緒回呼方法內設定中斷點。

  2. 在偵錯模式執行目標應用程式。

  3. 當應用程式在中斷點停止時,請執行增益集。

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 安全性

請參閱

參考

Thread2 介面

Freeze 多載

EnvDTE90 命名空間

IsFrozen

Thaw

其他資源

使用執行緒和處理序

Automation 物件模型圖表

HOW TO:使用執行緒視窗