次の方法で共有


CounterSample コンストラクタ (Int64, Int64, Int64, Int64, Int64, Int64, PerformanceCounterType, Int64)

CounterSample 構造体の新しいインスタンスを初期化し、CounterTimeStamp プロパティを渡された値に設定します。

名前空間: System.Diagnostics
アセンブリ: System (system.dll 内)

構文

'宣言
Public Sub New ( _
    rawValue As Long, _
    baseValue As Long, _
    counterFrequency As Long, _
    systemFrequency As Long, _
    timeStamp As Long, _
    timeStamp100nSec As Long, _
    counterType As PerformanceCounterType, _
    counterTimeStamp As Long _
)
'使用
Dim rawValue As Long
Dim baseValue As Long
Dim counterFrequency As Long
Dim systemFrequency As Long
Dim timeStamp As Long
Dim timeStamp100nSec As Long
Dim counterType As PerformanceCounterType
Dim counterTimeStamp As Long

Dim instance As New CounterSample(rawValue, baseValue, counterFrequency, systemFrequency, timeStamp, timeStamp100nSec, counterType, counterTimeStamp)
public CounterSample (
    long rawValue,
    long baseValue,
    long counterFrequency,
    long systemFrequency,
    long timeStamp,
    long timeStamp100nSec,
    PerformanceCounterType counterType,
    long counterTimeStamp
)
public:
CounterSample (
    long long rawValue, 
    long long baseValue, 
    long long counterFrequency, 
    long long systemFrequency, 
    long long timeStamp, 
    long long timeStamp100nSec, 
    PerformanceCounterType counterType, 
    long long counterTimeStamp
)
public CounterSample (
    long rawValue, 
    long baseValue, 
    long counterFrequency, 
    long systemFrequency, 
    long timeStamp, 
    long timeStamp100nSec, 
    PerformanceCounterType counterType, 
    long counterTimeStamp
)
public function CounterSample (
    rawValue : long, 
    baseValue : long, 
    counterFrequency : long, 
    systemFrequency : long, 
    timeStamp : long, 
    timeStamp100nSec : long, 
    counterType : PerformanceCounterType, 
    counterTimeStamp : long
)

パラメータ

  • rawValue
    パフォーマンス カウンタのサンプルに関連付けられている数値。
  • baseValue
    サンプルが複数のカウンタに基づいている場合にだけ使用されるカウンタの生のベース値。省略できます。
  • counterFrequency
    カウンタを読み取る頻度。
  • systemFrequency
    システムがカウンタを読み取る頻度。
  • timeStamp
    生のタイム スタンプ。
  • timeStamp100nSec
    信頼性の高い生のタイム スタンプ。
  • counterType
    このサンプルがスナップショットになるカウンタの種類を示す PerformanceCounterType
  • counterTimeStamp
    サンプルを取得した時刻。

解説

このコンストラクタを使用して、パフォーマンス カウンタの初期サンプルを取得した後で、サンプルを取得します。NextSample を呼び出したときに、これらのパラメータの値は自動的に設定されます。

使用例

      Dim myPerformanceCounter1 As New PerformanceCounter("Processor", _
                                                  "% Processor Time", "0")
      Dim myCounterSample1 As New CounterSample(10&, 20&, 30&, 40&, 50&, 60&, _
                                     PerformanceCounterType.AverageCount64)
      Console.WriteLine("CounterTimeStamp = " & myCounterSample1.CounterTimeStamp)

      Console.WriteLine("BaseValue = " & myCounterSample1.BaseValue)
      Console.WriteLine("RawValue = " & myCounterSample1.RawValue)
      Console.WriteLine("CounterFrequency = " & myCounterSample1.CounterFrequency)
      Console.WriteLine("SystemFrequency = " & myCounterSample1.SystemFrequency)
      Console.WriteLine("TimeStamp = " & myCounterSample1.TimeStamp)
      Console.WriteLine("TimeStamp100nSec = " & myCounterSample1.TimeStamp100nSec)
      Console.WriteLine("CounterType = " & myCounterSample1.CounterType.ToString)
      ' Hold the results of sample.
      myCounterSample1 = myPerformanceCounter1.NextSample()

      Console.WriteLine("BaseValue = " & myCounterSample1.BaseValue)
      Console.WriteLine("RawValue = " & myCounterSample1.RawValue)
      Console.WriteLine("CounterFrequency = " & myCounterSample1.CounterFrequency)
      Console.WriteLine("SystemFrequency = " & myCounterSample1.SystemFrequency)
      Console.WriteLine("TimeStamp = " & myCounterSample1.TimeStamp)
      Console.WriteLine("TimeStamp100nSec = " & myCounterSample1.TimeStamp100nSec)
      Console.WriteLine("CounterType = " & myCounterSample1.CounterType.ToString)

...
      Dim myPerformanceCounter2 As New PerformanceCounter("Processor", _
                                                   "% Processor Time", "0")
      Dim myCounterSample2 As New CounterSample(10&, 20&, 30&, 40&, 50&, 60&, _
                               PerformanceCounterType.AverageCount64, 300)
      Console.WriteLine("CounterTimeStamp = " & myCounterSample2.CounterTimeStamp)
      Console.WriteLine("BaseValue = " & myCounterSample2.BaseValue)
      Console.WriteLine("RawValue = " & myCounterSample2.RawValue)
      Console.WriteLine("CounterFrequency = " & myCounterSample2.CounterFrequency)
      Console.WriteLine("SystemFrequency = " & myCounterSample2.SystemFrequency)
      Console.WriteLine("TimeStamp = " & myCounterSample2.TimeStamp)
      Console.WriteLine("TimeStamp100nSec = " & myCounterSample2.TimeStamp100nSec)
      Console.WriteLine("CounterType = " & myCounterSample2.CounterType.ToString)
      Console.WriteLine("CounterTimeStamp = " & myCounterSample2.CounterTimeStamp)

      ' Hold the results of sample.
      myCounterSample2 = myPerformanceCounter2.NextSample()
      Console.WriteLine("BaseValue = " & myCounterSample2.BaseValue)
      Console.WriteLine("RawValue = " & myCounterSample2.RawValue)
      Console.WriteLine("CounterFrequency = " & myCounterSample2.CounterFrequency)
      Console.WriteLine("SystemFrequency = " & myCounterSample2.SystemFrequency)
      Console.WriteLine("TimeStamp = " & myCounterSample2.TimeStamp)
      Console.WriteLine("TimeStamp100nSec = " & myCounterSample2.TimeStamp100nSec)
      Console.WriteLine("CounterType = " & myCounterSample2.CounterType.ToString)
      Console.WriteLine("CounterTimeStamp = " & myCounterSample2.CounterTimeStamp)
      PerformanceCounter myPerformanceCounter1 = new PerformanceCounter
         ("Processor","% Processor Time", "0");
      CounterSample myCounterSample1 = new CounterSample(10L, 20L, 30L, 40L, 50L, 60L,
                           PerformanceCounterType.AverageCount64);
      Console.WriteLine("CounterTimeStamp = "+myCounterSample1.CounterTimeStamp);

      Console.WriteLine("BaseValue = "+myCounterSample1.BaseValue);
      Console.WriteLine("RawValue = "+myCounterSample1.RawValue);
      Console.WriteLine("CounterFrequency = "+myCounterSample1.CounterFrequency);
      Console.WriteLine("SystemFrequency = "+myCounterSample1.SystemFrequency);
      Console.WriteLine("TimeStamp = "+myCounterSample1.TimeStamp);
      Console.WriteLine("TimeStamp100nSec = "+myCounterSample1.TimeStamp100nSec);
      Console.WriteLine("CounterType = "+myCounterSample1.CounterType);
      // Hold the results of sample.
      myCounterSample1 = myPerformanceCounter1.NextSample();
      Console.WriteLine("BaseValue = "+myCounterSample1.BaseValue);
      Console.WriteLine("RawValue = "+myCounterSample1.RawValue);
      Console.WriteLine("CounterFrequency = "+myCounterSample1.CounterFrequency);
      Console.WriteLine("SystemFrequency = "+myCounterSample1.SystemFrequency);
      Console.WriteLine("TimeStamp = "+myCounterSample1.TimeStamp);
      Console.WriteLine("TimeStamp100nSec = "+myCounterSample1.TimeStamp100nSec);
      Console.WriteLine("CounterType = "+myCounterSample1.CounterType);

...
      PerformanceCounter myPerformanceCounter2 = new PerformanceCounter
         ("Processor","% Processor Time", "0");
      CounterSample myCounterSample2 = new CounterSample(10L, 20L, 30L, 40L, 50L, 60L,
                     PerformanceCounterType.AverageCount64, 300);
      Console.WriteLine("CounterTimeStamp = "+myCounterSample2.CounterTimeStamp);
      Console.WriteLine("BaseValue = "+myCounterSample2.BaseValue);
      Console.WriteLine("RawValue = "+myCounterSample2.RawValue);
      Console.WriteLine("CounterFrequency = "+myCounterSample2.CounterFrequency);
      Console.WriteLine("SystemFrequency = "+myCounterSample2.SystemFrequency);
      Console.WriteLine("TimeStamp = "+myCounterSample2.TimeStamp);
      Console.WriteLine("TimeStamp100nSec = "+myCounterSample2.TimeStamp100nSec);
      Console.WriteLine("CounterType = "+myCounterSample2.CounterType);
      Console.WriteLine("CounterTimeStamp = "+myCounterSample2.CounterTimeStamp);
      // Hold the results of sample.
      myCounterSample2 = myPerformanceCounter2.NextSample();
      Console.WriteLine("BaseValue = "+myCounterSample2.BaseValue);
      Console.WriteLine("RawValue = "+myCounterSample2.RawValue);
      Console.WriteLine("CounterFrequency = "+myCounterSample2.CounterFrequency);
      Console.WriteLine("SystemFrequency = "+myCounterSample2.SystemFrequency);
      Console.WriteLine("TimeStamp = "+myCounterSample2.TimeStamp);
      Console.WriteLine("TimeStamp100nSec = "+myCounterSample2.TimeStamp100nSec);
      Console.WriteLine("CounterType = "+myCounterSample2.CounterType);
      Console.WriteLine("CounterTimeStamp = "+myCounterSample2.CounterTimeStamp);
   PerformanceCounter^ myPerformanceCounter1 = gcnew PerformanceCounter(
      "Processor","% Processor Time","0" );
   CounterSample myCounterSample1( 10L, 20L, 30L, 40L, 50L, 60L,
     PerformanceCounterType::AverageCount64 );
   Console::WriteLine( "CounterTimeStamp = {0}", myCounterSample1.CounterTimeStamp );

   Console::WriteLine( "BaseValue = {0}", myCounterSample1.BaseValue );
   Console::WriteLine( "RawValue = {0}", myCounterSample1.RawValue );
   Console::WriteLine( "CounterFrequency = {0}", myCounterSample1.CounterFrequency );
   Console::WriteLine( "SystemFrequency = {0}", myCounterSample1.SystemFrequency );
   Console::WriteLine( "TimeStamp = {0}", myCounterSample1.TimeStamp );
   Console::WriteLine( "TimeStamp100nSec = {0}", myCounterSample1.TimeStamp100nSec );
   Console::WriteLine( "CounterType = {0}", myCounterSample1.CounterType );
   // Hold the results of sample.
   myCounterSample1 = myPerformanceCounter1->NextSample();
   Console::WriteLine( "BaseValue = {0}", myCounterSample1.BaseValue );
   Console::WriteLine( "RawValue = {0}", myCounterSample1.RawValue );
   Console::WriteLine( "CounterFrequency = {0}", myCounterSample1.CounterFrequency );
   Console::WriteLine( "SystemFrequency = {0}", myCounterSample1.SystemFrequency );
   Console::WriteLine( "TimeStamp = {0}", myCounterSample1.TimeStamp );
   Console::WriteLine( "TimeStamp100nSec = {0}", myCounterSample1.TimeStamp100nSec );
   Console::WriteLine( "CounterType = {0}", myCounterSample1.CounterType );

...
   PerformanceCounter^ myPerformanceCounter2 =
      gcnew PerformanceCounter( "Processor","% Processor Time","0" );
   CounterSample myCounterSample2( 10L, 20L, 30L, 40L, 50L, 60L,
     PerformanceCounterType::AverageCount64,300);
   Console::WriteLine( "CounterTimeStamp = {0}", myCounterSample2.CounterTimeStamp );
   Console::WriteLine( "BaseValue = {0}", myCounterSample2.BaseValue );
   Console::WriteLine( "RawValue = {0}", myCounterSample2.RawValue );
   Console::WriteLine( "CounterFrequency = {0}", myCounterSample2.CounterFrequency );
   Console::WriteLine( "SystemFrequency = {0}", myCounterSample2.SystemFrequency );
   Console::WriteLine( "TimeStamp = {0}", myCounterSample2.TimeStamp );
   Console::WriteLine( "TimeStamp100nSec = {0}", myCounterSample2.TimeStamp100nSec );
   Console::WriteLine( "CounterType = {0}", myCounterSample2.CounterType );
   Console::WriteLine( "CounterTimeStamp = {0}", myCounterSample2.CounterTimeStamp );
   // Hold the results of sample.
   myCounterSample2 = myPerformanceCounter2->NextSample();
   Console::WriteLine( "BaseValue = {0}", myCounterSample2.BaseValue );
   Console::WriteLine( "RawValue = {0}", myCounterSample2.RawValue );
   Console::WriteLine( "CounterFrequency = {0}", myCounterSample2.CounterFrequency );
   Console::WriteLine( "SystemFrequency = {0}", myCounterSample2.SystemFrequency );
   Console::WriteLine( "TimeStamp = {0}", myCounterSample2.TimeStamp );
   Console::WriteLine( "TimeStamp100nSec = {0}", myCounterSample2.TimeStamp100nSec );
   Console::WriteLine( "CounterType = {0}", myCounterSample2.CounterType );
   Console::WriteLine( "CounterTimeStamp = {0}", myCounterSample2.CounterTimeStamp );
        PerformanceCounter myPerformanceCounter1 = new PerformanceCounter(
            "Processor", "% Processor Time", "0");
        CounterSample myCounterSample1 = new CounterSample(10L, 20L, 30L, 40L, 
            50L, 60L, PerformanceCounterType.AverageCount64);
        Console.WriteLine("CounterTimeStamp = " 
            + myCounterSample1.get_CounterTimeStamp());

        Console.WriteLine("BaseValue = " + myCounterSample1.get_BaseValue());
        Console.WriteLine("RawValue = " + myCounterSample1.get_RawValue());
        Console.WriteLine("CounterFrequency = " 
            + myCounterSample1.get_CounterFrequency());
        Console.WriteLine("SystemFrequency = " 
            + myCounterSample1.get_SystemFrequency());
        Console.WriteLine("TimeStamp = " + myCounterSample1.get_TimeStamp());
        Console.WriteLine("TimeStamp100nSec = " 
            + myCounterSample1.get_TimeStamp100nSec());
        Console.WriteLine("CounterType = " 
            + myCounterSample1.get_CounterType());
        // Hold the results of sample.
        myCounterSample1 = myPerformanceCounter1.NextSample();
        Console.WriteLine("BaseValue = " + myCounterSample1.get_BaseValue());
        Console.WriteLine("RawValue = " + myCounterSample1.get_RawValue());
        Console.WriteLine("CounterFrequency = " 
            + myCounterSample1.get_CounterFrequency());
        Console.WriteLine("SystemFrequency = " 
            + myCounterSample1.get_SystemFrequency());
        Console.WriteLine("TimeStamp = " 
            + myCounterSample1.get_TimeStamp());
        Console.WriteLine("TimeStamp100nSec = " 
            + myCounterSample1.get_TimeStamp100nSec());
        Console.WriteLine("CounterType = " 
            + myCounterSample1.get_CounterType());

...
        PerformanceCounter myPerformanceCounter2 = new PerformanceCounter(
            "Processor", "% Processor Time", "0");
        CounterSample myCounterSample2 = new CounterSample(10L, 20L, 30L, 
            40L, 50L, 60L, PerformanceCounterType.AverageCount64, 300);
        Console.WriteLine("CounterTimeStamp = " 
            + myCounterSample2.get_CounterTimeStamp());
        Console.WriteLine("BaseValue = " + myCounterSample2.get_BaseValue());
        Console.WriteLine("RawValue = " + myCounterSample2.get_RawValue());
        Console.WriteLine("CounterFrequency = " 
            + myCounterSample2.get_CounterFrequency());
        Console.WriteLine("SystemFrequency = " 
            + myCounterSample2.get_SystemFrequency());
        Console.WriteLine("TimeStamp = " + myCounterSample2.get_TimeStamp());
        Console.WriteLine("TimeStamp100nSec = " 
            + myCounterSample2.get_TimeStamp100nSec());
        Console.WriteLine("CounterType = " 
            + myCounterSample2.get_CounterType());
        Console.WriteLine("CounterTimeStamp = " 
            + myCounterSample2.get_CounterTimeStamp());
        // Hold the results of sample.
        myCounterSample2 = myPerformanceCounter2.NextSample();
        Console.WriteLine("BaseValue = " + myCounterSample2.get_BaseValue());
        Console.WriteLine("RawValue = " + myCounterSample2.get_RawValue());
        Console.WriteLine("CounterFrequency = " 
            + myCounterSample2.get_CounterFrequency());
        Console.WriteLine("SystemFrequency = " 
            + myCounterSample2.get_SystemFrequency());
        Console.WriteLine("TimeStamp = " + myCounterSample2.get_TimeStamp());
        Console.WriteLine("TimeStamp100nSec = " 
            + myCounterSample2.get_TimeStamp100nSec());
        Console.WriteLine("CounterType = " 
            + myCounterSample2.get_CounterType());
        Console.WriteLine("CounterTimeStamp = " 
            + myCounterSample2.get_CounterTimeStamp());

プラットフォーム

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。

バージョン情報

.NET Framework

サポート対象 : 2.0、1.1、1.0

参照

関連項目

CounterSample 構造体
CounterSample メンバ
System.Diagnostics 名前空間