PerformanceCounter 類別

定義

代表 Windows NT 效能計數器元件。

public ref class PerformanceCounter sealed : System::ComponentModel::Component, System::ComponentModel::ISupportInitialize
public sealed class PerformanceCounter : System.ComponentModel.Component, System.ComponentModel.ISupportInitialize
type PerformanceCounter = class
    inherit Component
    interface ISupportInitialize
Public NotInheritable Class PerformanceCounter
Inherits Component
Implements ISupportInitialize
繼承
PerformanceCounter
實作

範例

下列程式碼範例示範 如何使用 PerformanceCounter 類別來建立及使用 AverageCount64 計數器類型。 此範例會建立類別、設定計數器、從計數器收集資料,以及呼叫 CounterSampleCalculator 類別來解譯效能計數器資料。 中繼和最終結果會顯示在主控台視窗中。 如需其他效能計數器型別的其他範例,請參閱 PerformanceCounterType 列舉。

#using <System.dll>

using namespace System;
using namespace System::Collections;
using namespace System::Collections::Specialized;
using namespace System::Diagnostics;

// Output information about the counter sample.
void OutputSample( CounterSample s )
{
   Console::WriteLine( "\r\n+++++++++++" );
   Console::WriteLine( "Sample values - \r\n" );
   Console::WriteLine( "   BaseValue        = {0}", s.BaseValue );
   Console::WriteLine( "   CounterFrequency = {0}", s.CounterFrequency );
   Console::WriteLine( "   CounterTimeStamp = {0}", s.CounterTimeStamp );
   Console::WriteLine( "   CounterType      = {0}", s.CounterType );
   Console::WriteLine( "   RawValue         = {0}", s.RawValue );
   Console::WriteLine( "   SystemFrequency  = {0}", s.SystemFrequency );
   Console::WriteLine( "   TimeStamp        = {0}", s.TimeStamp );
   Console::WriteLine( "   TimeStamp100nSec = {0}", s.TimeStamp100nSec );
   Console::WriteLine( "++++++++++++++++++++++" );
}

//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++
//    Description - This counter type shows how many items are processed, on average,
//        during an operation. Counters of this type display a ratio of the items 
//        processed (such as bytes sent) to the number of operations completed. The  
//        ratio is calculated by comparing the number of items processed during the 
//        last interval to the number of operations completed during the last interval. 
// Generic type - Average
//      Formula - (N1 - N0) / (D1 - D0), where the numerator (N) represents the number 
//        of items processed during the last sample interval and the denominator (D) 
//        represents the number of operations completed during the last two sample 
//        intervals. 
//    Average (Nx - N0) / (Dx - D0)  
//    Example PhysicalDisk\ Avg. Disk Bytes/Transfer 
//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++
float MyComputeCounterValue( CounterSample s0, CounterSample s1 )
{
   float numerator = (float)s1.RawValue - (float)s0.RawValue;
   float denomenator = (float)s1.BaseValue - (float)s0.BaseValue;
   float counterValue = numerator / denomenator;
   return counterValue;
}

bool SetupCategory()
{
   if (  !PerformanceCounterCategory::Exists( "AverageCounter64SampleCategory" ) )
   {
      CounterCreationDataCollection^ CCDC = gcnew CounterCreationDataCollection;
      
      // Add the counter.
      CounterCreationData^ averageCount64 = gcnew CounterCreationData;
      averageCount64->CounterType = PerformanceCounterType::AverageCount64;
      averageCount64->CounterName = "AverageCounter64Sample";
      CCDC->Add( averageCount64 );
      
      // Add the base counter.
      CounterCreationData^ averageCount64Base = gcnew CounterCreationData;
      averageCount64Base->CounterType = PerformanceCounterType::AverageBase;
      averageCount64Base->CounterName = "AverageCounter64SampleBase";
      CCDC->Add( averageCount64Base );
      
      // Create the category.
      PerformanceCounterCategory::Create( "AverageCounter64SampleCategory", "Demonstrates usage of the AverageCounter64 performance counter type.", CCDC );
      return (true);
   }
   else
   {
      Console::WriteLine( "Category exists - AverageCounter64SampleCategory" );
      return (false);
   }
}

void CreateCounters( PerformanceCounter^% PC, PerformanceCounter^% BPC )
{
   
   // Create the counters.
   PC = gcnew PerformanceCounter( "AverageCounter64SampleCategory","AverageCounter64Sample",false );

   BPC = gcnew PerformanceCounter( "AverageCounter64SampleCategory","AverageCounter64SampleBase",false );
   PC->RawValue = 0;
   BPC->RawValue = 0;
}
void CollectSamples( ArrayList^ samplesList, PerformanceCounter^ PC, PerformanceCounter^ BPC )
{
   Random^ r = gcnew Random( DateTime::Now.Millisecond );

   // Loop for the samples.
   for ( int j = 0; j < 100; j++ )
   {
      int value = r->Next( 1, 10 );
      Console::Write( "{0} = {1}", j, value );
      PC->IncrementBy( value );
      BPC->Increment();
      if ( (j % 10) == 9 )
      {
         OutputSample( PC->NextSample() );
         samplesList->Add( PC->NextSample() );
      }
      else
            Console::WriteLine();
      System::Threading::Thread::Sleep( 50 );
   }
}

void CalculateResults( ArrayList^ samplesList )
{
   for ( int i = 0; i < (samplesList->Count - 1); i++ )
   {
      // Output the sample.
      OutputSample(  *safe_cast<CounterSample^>(samplesList[ i ]) );
      OutputSample(  *safe_cast<CounterSample^>(samplesList[ i + 1 ]) );
      
      // Use .NET to calculate the counter value.
      Console::WriteLine( ".NET computed counter value = {0}", CounterSampleCalculator::ComputeCounterValue(  *safe_cast<CounterSample^>(samplesList[ i ]),  *safe_cast<CounterSample^>(samplesList[ i + 1 ]) ) );
      
      // Calculate the counter value manually.
      Console::WriteLine( "My computed counter value = {0}", MyComputeCounterValue(  *safe_cast<CounterSample^>(samplesList[ i ]),  *safe_cast<CounterSample^>(samplesList[ i + 1 ]) ) );
   }
}

int main()
{
   ArrayList^ samplesList = gcnew ArrayList;
   PerformanceCounter^ PC;
   PerformanceCounter^ BPC;
   SetupCategory();
   CreateCounters( PC, BPC );
   CollectSamples( samplesList, PC, BPC );
   CalculateResults( samplesList );
}

using System;
using System.Collections;
using System.Collections.Specialized;
using System.Diagnostics;

public class App {

    private static PerformanceCounter avgCounter64Sample;
    private static PerformanceCounter avgCounter64SampleBase;

    public static void Main()
    {

        ArrayList samplesList = new ArrayList();

        // If the category does not exist, create the category and exit.
        // Performance counters should not be created and immediately used.
        // There is a latency time to enable the counters, they should be created
        // prior to executing the application that uses the counters.
        // Execute this sample a second time to use the category.
        if (SetupCategory())
            return;
        CreateCounters();
        CollectSamples(samplesList);
        CalculateResults(samplesList);
    }

    private static bool SetupCategory()
    {
        if ( !PerformanceCounterCategory.Exists("AverageCounter64SampleCategory") )
        {

            CounterCreationDataCollection counterDataCollection = new CounterCreationDataCollection();

            // Add the counter.
            CounterCreationData averageCount64 = new CounterCreationData();
            averageCount64.CounterType = PerformanceCounterType.AverageCount64;
            averageCount64.CounterName = "AverageCounter64Sample";
            counterDataCollection.Add(averageCount64);

            // Add the base counter.
            CounterCreationData averageCount64Base = new CounterCreationData();
            averageCount64Base.CounterType = PerformanceCounterType.AverageBase;
            averageCount64Base.CounterName = "AverageCounter64SampleBase";
            counterDataCollection.Add(averageCount64Base);

            // Create the category.
            PerformanceCounterCategory.Create("AverageCounter64SampleCategory",
                "Demonstrates usage of the AverageCounter64 performance counter type.",
                PerformanceCounterCategoryType.SingleInstance, counterDataCollection);

            return(true);
        }
        else
        {
            Console.WriteLine("Category exists - AverageCounter64SampleCategory");
            return(false);
        }
    }

    private static void CreateCounters()
    {
        // Create the counters.

        avgCounter64Sample = new PerformanceCounter("AverageCounter64SampleCategory",
            "AverageCounter64Sample",
            false);


        avgCounter64SampleBase = new PerformanceCounter("AverageCounter64SampleCategory",
            "AverageCounter64SampleBase",
            false);

        avgCounter64Sample.RawValue=0;
        avgCounter64SampleBase.RawValue=0;
    }
    private static void CollectSamples(ArrayList samplesList)
    {

        Random r = new Random( DateTime.Now.Millisecond );

        // Loop for the samples.
        for (int j = 0; j < 100; j++)
        {

            int value = r.Next(1, 10);
            Console.Write(j + " = " + value);

            avgCounter64Sample.IncrementBy(value);

            avgCounter64SampleBase.Increment();

            if ((j % 10) == 9)
            {
                OutputSample(avgCounter64Sample.NextSample());
                samplesList.Add( avgCounter64Sample.NextSample() );
            }
            else
            {
                Console.WriteLine();
            }

            System.Threading.Thread.Sleep(50);
        }
    }

    private static void CalculateResults(ArrayList samplesList)
    {
        for(int i = 0; i < (samplesList.Count - 1); i++)
        {
            // Output the sample.
            OutputSample( (CounterSample)samplesList[i] );
            OutputSample( (CounterSample)samplesList[i+1] );

            // Use .NET to calculate the counter value.
            Console.WriteLine(".NET computed counter value = " +
                CounterSampleCalculator.ComputeCounterValue((CounterSample)samplesList[i],
                (CounterSample)samplesList[i+1]) );

            // Calculate the counter value manually.
            Console.WriteLine("My computed counter value = " +
                MyComputeCounterValue((CounterSample)samplesList[i],
                (CounterSample)samplesList[i+1]) );
        }
    }

    //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++
    //    Description - This counter type shows how many items are processed, on average,
    //        during an operation. Counters of this type display a ratio of the items
    //        processed (such as bytes sent) to the number of operations completed. The
    //        ratio is calculated by comparing the number of items processed during the
    //        last interval to the number of operations completed during the last interval.
    // Generic type - Average
    //      Formula - (N1 - N0) / (D1 - D0), where the numerator (N) represents the number
    //        of items processed during the last sample interval and the denominator (D)
    //        represents the number of operations completed during the last two sample
    //        intervals.
    //    Average (Nx - N0) / (Dx - D0)
    //    Example PhysicalDisk\ Avg. Disk Bytes/Transfer
    //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++
    private static Single MyComputeCounterValue(CounterSample s0, CounterSample s1)
    {
        Single numerator = (Single)s1.RawValue - (Single)s0.RawValue;
        Single denomenator = (Single)s1.BaseValue - (Single)s0.BaseValue;
        Single counterValue = numerator / denomenator;
        return(counterValue);
    }

    // Output information about the counter sample.
    private static void OutputSample(CounterSample s)
    {
        Console.WriteLine("\r\n+++++++++++");
        Console.WriteLine("Sample values - \r\n");
        Console.WriteLine("   BaseValue        = " + s.BaseValue);
        Console.WriteLine("   CounterFrequency = " + s.CounterFrequency);
        Console.WriteLine("   CounterTimeStamp = " + s.CounterTimeStamp);
        Console.WriteLine("   CounterType      = " + s.CounterType);
        Console.WriteLine("   RawValue         = " + s.RawValue);
        Console.WriteLine("   SystemFrequency  = " + s.SystemFrequency);
        Console.WriteLine("   TimeStamp        = " + s.TimeStamp);
        Console.WriteLine("   TimeStamp100nSec = " + s.TimeStamp100nSec);
        Console.WriteLine("++++++++++++++++++++++");
    }
}
Imports System.Collections
Imports System.Collections.Specialized
Imports System.Diagnostics

 _

Public Class App

    Private Shared avgCounter64Sample As PerformanceCounter
    Private Shared avgCounter64SampleBase As PerformanceCounter


    Public Shared Sub Main()

        Dim samplesList As New ArrayList()
        'If the category does not exist, create the category and exit.
        'Performance counters should not be created and immediately used.
        'There is a latency time to enable the counters, they should be created
        'prior to executing the application that uses the counters.
        'Execute this sample a second time to use the counters.
        If Not (SetupCategory()) Then
            CreateCounters()
            CollectSamples(samplesList)
            CalculateResults(samplesList)
        End If

    End Sub

    Private Shared Function SetupCategory() As Boolean
        If Not PerformanceCounterCategory.Exists("AverageCounter64SampleCategory") Then

            Dim counterDataCollection As New CounterCreationDataCollection()

            ' Add the counter.
            Dim averageCount64 As New CounterCreationData()
            averageCount64.CounterType = PerformanceCounterType.AverageCount64
            averageCount64.CounterName = "AverageCounter64Sample"
            counterDataCollection.Add(averageCount64)

            ' Add the base counter.
            Dim averageCount64Base As New CounterCreationData()
            averageCount64Base.CounterType = PerformanceCounterType.AverageBase
            averageCount64Base.CounterName = "AverageCounter64SampleBase"
            counterDataCollection.Add(averageCount64Base)

            ' Create the category.
            PerformanceCounterCategory.Create("AverageCounter64SampleCategory", _
               "Demonstrates usage of the AverageCounter64 performance counter type.", _
                      PerformanceCounterCategoryType.SingleInstance, counterDataCollection)

            Return True
        Else
            Console.WriteLine("Category exists - AverageCounter64SampleCategory")
            Return False
        End If
    End Function 'SetupCategory

    Private Shared Sub CreateCounters()
        ' Create the counters.

        avgCounter64Sample = New PerformanceCounter("AverageCounter64SampleCategory", "AverageCounter64Sample", False)

        avgCounter64SampleBase = New PerformanceCounter("AverageCounter64SampleCategory", "AverageCounter64SampleBase", False)

        avgCounter64Sample.RawValue = 0
        avgCounter64SampleBase.RawValue = 0
    End Sub

    Private Shared Sub CollectSamples(ByVal samplesList As ArrayList)

        Dim r As New Random(DateTime.Now.Millisecond)

        ' Loop for the samples.
        Dim j As Integer
        For j = 0 To 99

            Dim value As Integer = r.Next(1, 10)
            Console.Write(j.ToString() + " = " + value.ToString())

            avgCounter64Sample.IncrementBy(value)

            avgCounter64SampleBase.Increment()

            If j Mod 10 = 9 Then
                OutputSample(avgCounter64Sample.NextSample())
                samplesList.Add(avgCounter64Sample.NextSample())
            Else
                Console.WriteLine()
            End If
            System.Threading.Thread.Sleep(50)
        Next j
    End Sub

    Private Shared Sub CalculateResults(ByVal samplesList As ArrayList)
        Dim i As Integer
        For i = 0 To (samplesList.Count - 1) - 1
            ' Output the sample.
            OutputSample(CType(samplesList(i), CounterSample))
            OutputSample(CType(samplesList((i + 1)), CounterSample))

            ' Use .NET to calculate the counter value.
            Console.WriteLine(".NET computed counter value = " + CounterSampleCalculator.ComputeCounterValue(CType(samplesList(i), CounterSample), CType(samplesList((i + 1)), CounterSample)).ToString())

            ' Calculate the counter value manually.
            Console.WriteLine("My computed counter value = " + MyComputeCounterValue(CType(samplesList(i), CounterSample), CType(samplesList((i + 1)), CounterSample)).ToString())
        Next i
    End Sub

    '++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++
    '	Description - This counter type shows how many items are processed, on average,
    '		during an operation. Counters of this type display a ratio of the items 
    '		processed (such as bytes sent) to the number of operations completed. The  
    '		ratio is calculated by comparing the number of items processed during the 
    '		last interval to the number of operations completed during the last interval. 
    ' Generic type - Average
    '  	Formula - (N1 - N0) / (D1 - D0), where the numerator (N) represents the number 
    '		of items processed during the last sample interval and the denominator (D) 
    '		represents the number of operations completed during the last two sample 
    '		intervals. 
    '	Average (Nx - N0) / (Dx - D0)  
    '	Example PhysicalDisk\ Avg. Disk Bytes/Transfer 
    '++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++
    Private Shared Function MyComputeCounterValue(ByVal s0 As CounterSample, ByVal s1 As CounterSample) As [Single]
        Dim numerator As [Single] = CType(s1.RawValue, [Single]) - CType(s0.RawValue, [Single])
        Dim denomenator As [Single] = CType(s1.BaseValue, [Single]) - CType(s0.BaseValue, [Single])
        Dim counterValue As [Single] = numerator / denomenator
        Return counterValue
    End Function 'MyComputeCounterValue

    ' Output information about the counter sample.
    Private Shared Sub OutputSample(ByVal s As CounterSample)
        Console.WriteLine(ControlChars.Lf + ControlChars.Cr + "+++++++++++")
        Console.WriteLine("Sample values - " + ControlChars.Lf + ControlChars.Cr)
        Console.WriteLine(("   BaseValue        = " + s.BaseValue.ToString()))
        Console.WriteLine(("   CounterFrequency = " + s.CounterFrequency.ToString()))
        Console.WriteLine(("   CounterTimeStamp = " + s.CounterTimeStamp.ToString()))
        Console.WriteLine(("   CounterType      = " + s.CounterType.ToString()))
        Console.WriteLine(("   RawValue         = " + s.RawValue.ToString()))
        Console.WriteLine(("   SystemFrequency  = " + s.SystemFrequency.ToString()))
        Console.WriteLine(("   TimeStamp        = " + s.TimeStamp.ToString()))
        Console.WriteLine(("   TimeStamp100nSec = " + s.TimeStamp100nSec.ToString()))
        Console.WriteLine("++++++++++++++++++++++")
    End Sub
End Class

備註

元件 PerformanceCounter 可用於讀取現有的預先定義或自訂計數器,以及將) 效能資料寫入至自訂計數器 (。

Windows 效能監視器的 [新增計數器] 對話方塊中列出許多預先定義的計數器。 若要瞭解.NET Framework效能計數器,請參閱效能計數器

此型別代表 IDisposable 介面。 當您完成使用型別時,您應該直接或間接處置它。 若要直接處置型別,請呼叫其 try/catch 區塊中的 Dispose 方法。 若要間接處置它,請使用語言建構函式,例如 using (在 C# 中) 或 Using (在 Visual Basic 中)。 如需詳細資訊,請參閱 IDisposable 介面文章中的<使用實作 IDisposable 的物件>一節。

重要

在 .NET Framework 1.0 和 1.1 版中,此類別需要完全信任立即呼叫端。 從 .NET Framework 2.0 版開始,此類別需要 PerformanceCounterPermission 特定動作。 強烈建議 PerformanceCounterPermission 不要授與半信任的程式碼。 讀取和寫入效能計數器的功能可讓程式碼執行動作,例如列舉執行中的進程,並取得它們的相關資訊。

此外,將 PerformanceCounter 物件傳遞至較不受信任的程式碼可能會建立安全性問題。 絕對不要將效能計數器物件,例如 PerformanceCounterCategoryPerformanceCounter 傳遞至較不受信任的程式碼。

若要從效能計數器讀取,請建立 類別的 PerformanceCounter 實例、設定 CategoryNameCounterName 和 ,選擇性地設定 InstanceNameMachineName 屬性,然後呼叫 NextValue 方法來讀取效能計數器。

若要發佈效能計數器資料,請使用 PerformanceCounterCategory.Create 方法來建立一或多個自訂計數器、建立 類別的 PerformanceCounter 實例、設定 CategoryNameCounterName 和、選擇性或 InstanceName 屬性,然後呼叫 IncrementByIncrementMachineName Decrement 方法,或設定 RawValue 屬性來變更自訂計數器的值。

注意

IncrementIncrementByDecrement 方法會使用 interlocks 來更新計數器值。 這有助於在多執行緒或多進程案例中保持計數器值正確,但也會導致效能降低。 如果您不需要連結作業所提供的精確度,您可以直接更新 RawValue 屬性,最多 5 倍的效能改進。 不過,在多執行緒案例中,可能會忽略計數器值的一些更新,導致資料不正確。

計數器是收集效能資料的機制。 登錄會儲存所有計數器的名稱,每個計數器都與系統功能的特定區域相關。 範例包括處理器的忙碌時間、記憶體使用量,或透過網路連線收到的位元組數目。

每個計數器都是透過其名稱和位置唯一識別。 與檔案路徑包含磁片磁碟機、目錄、一或多個子目錄,以及檔案名相同,計數器資訊包含四個元素:電腦、類別、類別、類別實例和計數器名稱。

計數器資訊必須包含計數器測量資料的類別或效能物件。 電腦的類別包括實體元件,例如處理器、磁片和記憶體。 也有系統類別,例如進程和執行緒。 每一個類別都與電腦內的功能專案相關,並已指派一組標準計數器。 這些物件會列在 [Windows 2000 系統監視器] 內 [新增計數器] 對話方塊的 [效能物件] 下拉式清單中,而且您必須將它們包含在計數器路徑中。 效能資料會依與其相關的類別分組。

在某些情況下,可以存在相同類別的數個複本。 例如,數個進程和執行緒會同時執行,而有些電腦包含一個以上的處理器。 類別複本稱為類別實例,而且每個實例都有一組指派給它的標準計數器。 如果類別可以有多個實例,則必須在計數器資訊中包含實例規格。

若要取得需要初始或先前值來執行必要計算之計數器的效能資料,請呼叫 NextValue 方法兩次,並使用應用程式需要傳回的資訊。

注意

隨 .NET Framework 2.0 一起安裝的效能計數器類別會使用不同的共用記憶體,而每個效能計數器類別都有自己的記憶體。 您可以在登錄機碼中建立名為 FileMappingSize 的 DWORD,以指定個別共用記憶體的大小,HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ <category name> \Performance。 FileMappingSize 值會設定為類別的共用記憶體大小。 預設大小為十進位131072。 如果 FileMappingSize 值不存在,則會 fileMappingSize 使用Machine.config檔案中指定的元素屬性值 performanceCounters ,因而造成組態檔處理的額外負荷。 您可以藉由在登錄中設定檔案對應大小,來實現應用程式啟動的效能改善。 如需檔案對應大小的詳細資訊,請參閱 < performanceCounters >

建構函式

PerformanceCounter()

初始化 PerformanceCounter 類別的新的、唯讀的執行個體,而不將執行個體與任何系統或自訂效能計數器相關聯。

PerformanceCounter(String, String)

初始化 PerformanceCounter 類別的新的、唯讀的執行個體,並將其與本機電腦上指定的系統或自訂效能計數器相關聯。 這個建構函式 (Constructor) 要求分類包含單一執行個體。

PerformanceCounter(String, String, Boolean)

初始化 PerformanceCounter 類別的新的、唯讀或讀取/寫入執行個體,並將其與本機電腦上指定的系統或自訂效能計數器相關聯。 這個建構函式要求分類包含單一執行個體。

PerformanceCounter(String, String, String)

初始化 PerformanceCounter 類別的新的、唯讀的執行個體,並將其與本機電腦上指定的系統或自訂效能計數器和分類執行個體相關聯。

PerformanceCounter(String, String, String, Boolean)

初始化 PerformanceCounter 類別的新的、唯讀或讀取/寫入執行個體,並將其與本機電腦上指定的系統或自訂效能計數器和分類執行個體相關聯。

PerformanceCounter(String, String, String, String)

初始化 PerformanceCounter 類別的新的、唯讀的執行個體,並將其與指定電腦上指定的系統或自訂效能計數器和分類執行個體相關聯。

欄位

DefaultFileMappingSize
已過時。
已過時。
已過時。

指定效能計數器所共用之全域記憶體的大小 (以位元組計)。 預設大小為 524,288 個位元組。

屬性

CanRaiseEvents

取得值,指出元件是否能引發事件。

(繼承來源 Component)
CategoryName

取得或設定這個效能計數器的效能計數器分類的名稱。

Container

取得包含 IContainerComponent

(繼承來源 Component)
CounterHelp

取得這個效能計數器的描述。

CounterName

取得或設定與這個 PerformanceCounter 執行個體相關的效能計數器的名稱。

CounterType

取得相關的效能計數器的計數器型別。

DesignMode

取得值,指出 Component 目前是否處於設計模式。

(繼承來源 Component)
Events

取得附加在這個 Component 上的事件處理常式清單。

(繼承來源 Component)
InstanceLifetime

取得或設定處理序的存留期 (Lifetime)。

InstanceName

取得或設定這個效能計數器的執行個體名稱。

MachineName

取得或設定這個效能計數器的電腦名稱。

RawValue

取得或設定這個計數器的未經處理或未經計算的值。

ReadOnly

取得或設定數值,表示 PerformanceCounter 執行個體是否處於唯讀模式。

Site

取得或設定 ComponentISite

(繼承來源 Component)

方法

BeginInit()

開始初始化用於表單或為另一元件所使用的 PerformanceCounter 執行個體。 初始化會於執行階段時執行。

Close()

關閉效能計數器,並釋放這個效能計數器執行個體所配置的所有資源。

CloseSharedResources()

釋放由計數器配置的效能計數器程式庫的共用狀態。

CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。

(繼承來源 MarshalByRefObject)
Decrement()

經由有效率的不可部分完成的作業 (Atomic Operation),將相關的效能計數器逐一遞減。

Dispose()

釋放 Component 所使用的所有資源。

(繼承來源 Component)
Dispose(Boolean)

釋放 Component 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。

(繼承來源 Component)
EndInit()

結束初始化用於表單或為另一元件所使用的 PerformanceCounter 執行個體。 初始化會於執行階段時執行。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetLifetimeService()
已過時。

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。

(繼承來源 MarshalByRefObject)
GetService(Type)

傳回表示 Component 或其 Container 所提供之服務的物件。

(繼承來源 Component)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
Increment()

經由有效率的不可部分完成的作業,將相關的效能計數器逐一遞增。

IncrementBy(Int64)

經由有效率的不可部分完成的作業,將相關的效能計數器值按指定的數量遞增或遞減。

InitializeLifetimeService()
已過時。

取得存留期服務物件,以控制這個執行個體的存留期原則。

(繼承來源 MarshalByRefObject)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
MemberwiseClone(Boolean)

建立目前 MarshalByRefObject 物件的淺層複本。

(繼承來源 MarshalByRefObject)
NextSample()

取得計數器範例,並為其傳回未經處理或未計算的值。

NextValue()

取得計數器樣本,並為其傳回計算過的值。

RemoveInstance()

刪除由 PerformanceCounter 物件 InstanceName 屬性所指定的分類執行個體。

ToString()

傳回任何包含 Component 名稱的 String。 不應覆寫此方法。

(繼承來源 Component)

事件

Disposed

Dispose() 方法的呼叫處置元件時,就會發生。

(繼承來源 Component)

適用於

另請參閱