مشاركة عبر


Thread.IsAlive الخاصية

يحصل على ما إذا كان مؤشر ترابط المشار إليه هو مازال نشطاً.

مساحة الاسم:  EnvDTE
التجميع:  EnvDTE (في EnvDTE.dll)

بناء الجملة

'إقرار
ReadOnly Property IsAlive As Boolean
    Get
bool IsAlive { get; }
property bool IsAlive {
    bool get ();
}
abstract IsAlive : bool
function get IsAlive () : boolean

قيمة الخاصية

النوع: System.Boolean
قيمة منطقية

ملاحظات

بإرجاع trueإذا كان مؤشر ترابط المشار إليه هو النشاط؛ otherwهوe، false.

ملاحظة

قد تتغير الولاية مؤشر ترابط قبل إرجاع هذه دالة.

أمثلة

يوضح المثال التالي كيفية إلى تستخدم في IsAliveخاصية.

لاختبار هذه خاصية

  1. تعيين نقطة توقف داخل استدعاء مؤشر ترابط العامل أسلوب.

  2. قم بتشغيل تطبيق الهدف في الوضع التصحيح.

  3. عند إيقاف تشغيل تطبيق على نقطة الإيقاف، قم بتشغيل الوظيفة الإضافية.

public static void TestThreadProperties(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 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(EnvDTE.Thread 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);
    }
}
Shared Sub ThreadProperties(ByRef dte As EnvDTE.DTE)
    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 EnvDTE.Thread 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()
    Next
    MessageBox.Show(str, "Thread Test - Properties")
End Sub

أمن NET Framework.

راجع أيضًَا

المرجع

Thread واجهة

Thread الأعضاء

EnvDTE مساحة الاسم