CounterSample Construtores

Definição

Inicializa uma nova instância da estrutura CounterSample.

Sobrecargas

CounterSample(Int64, Int64, Int64, Int64, Int64, Int64, PerformanceCounterType)

Inicializa uma nova instância da estrutura CounterSample e define a propriedade CounterTimeStamp como 0 (zero).

CounterSample(Int64, Int64, Int64, Int64, Int64, Int64, PerformanceCounterType, Int64)

Inicializa uma nova instância da estrutura CounterSample e define a propriedade CounterTimeStamp como o valor que é passado.

CounterSample(Int64, Int64, Int64, Int64, Int64, Int64, PerformanceCounterType)

Origem:
CounterSample.cs
Origem:
CounterSample.cs
Origem:
CounterSample.cs

Inicializa uma nova instância da estrutura CounterSample e define a propriedade CounterTimeStamp como 0 (zero).

public:
 CounterSample(long rawValue, long baseValue, long counterFrequency, long systemFrequency, long timeStamp, long timeStamp100nSec, System::Diagnostics::PerformanceCounterType counterType);
public CounterSample (long rawValue, long baseValue, long counterFrequency, long systemFrequency, long timeStamp, long timeStamp100nSec, System.Diagnostics.PerformanceCounterType counterType);
new System.Diagnostics.CounterSample : int64 * int64 * int64 * int64 * int64 * int64 * System.Diagnostics.PerformanceCounterType -> System.Diagnostics.CounterSample
Public Sub New (rawValue As Long, baseValue As Long, counterFrequency As Long, systemFrequency As Long, timeStamp As Long, timeStamp100nSec As Long, counterType As PerformanceCounterType)

Parâmetros

rawValue
Int64

O valor numérico associado à amostra do contador de desempenho.

baseValue
Int64

Um valor bruto base opcional para o contador, para ser usado apenas se a amostra for baseada em vários contadores.

counterFrequency
Int64

A frequência com que o contador é lido.

systemFrequency
Int64

A frequência com que o sistema lê do contador.

timeStamp
Int64

O carimbo de data/hora bruto.

timeStamp100nSec
Int64

O carimbo de data/hora bruto de alta fidelidade.

counterType
PerformanceCounterType

Um objeto PerformanceCounterType que indica o tipo do contador para o qual esta amostra é um instantâneo.

Comentários

Use esse construtor para obter uma amostra inicial do contador de desempenho. O Monitor do Sistema fornece valores para esses parâmetros automaticamente quando você chama o NextSample método pela primeira vez.

Aplica-se a

CounterSample(Int64, Int64, Int64, Int64, Int64, Int64, PerformanceCounterType, Int64)

Origem:
CounterSample.cs
Origem:
CounterSample.cs
Origem:
CounterSample.cs

Inicializa uma nova instância da estrutura CounterSample e define a propriedade CounterTimeStamp como o valor que é passado.

public:
 CounterSample(long rawValue, long baseValue, long counterFrequency, long systemFrequency, long timeStamp, long timeStamp100nSec, System::Diagnostics::PerformanceCounterType counterType, long counterTimeStamp);
public CounterSample (long rawValue, long baseValue, long counterFrequency, long systemFrequency, long timeStamp, long timeStamp100nSec, System.Diagnostics.PerformanceCounterType counterType, long counterTimeStamp);
new System.Diagnostics.CounterSample : int64 * int64 * int64 * int64 * int64 * int64 * System.Diagnostics.PerformanceCounterType * int64 -> System.Diagnostics.CounterSample
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)

Parâmetros

rawValue
Int64

O valor numérico associado à amostra do contador de desempenho.

baseValue
Int64

Um valor bruto base opcional para o contador, para ser usado apenas se a amostra for baseada em vários contadores.

counterFrequency
Int64

A frequência com que o contador é lido.

systemFrequency
Int64

A frequência com que o sistema lê do contador.

timeStamp
Int64

O carimbo de data/hora bruto.

timeStamp100nSec
Int64

O carimbo de data/hora bruto de alta fidelidade.

counterType
PerformanceCounterType

Um objeto PerformanceCounterType que indica o tipo do contador para o qual esta amostra é um instantâneo.

counterTimeStamp
Int64

A hora em que a amostra foi realizada.

Exemplos

O exemplo a seguir demonstra como inicializar uma nova CounterSample estrutura, passando valores para os rawValueparâmetros , baseValue, counterFrequency, systemFrequency, timeStamptimeStamp100nSec, counterType, e counterTimeStamp . Depois de criar a CounterSample estrutura, o exemplo exibe os valores de propriedade para o CounterSample na janela do console.

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 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);
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)
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 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);
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)

Comentários

Use esse construtor para obter exemplos depois de já ter feito uma amostra inicial do contador de desempenho. O Monitor do Sistema fornece valores para esses parâmetros automaticamente quando você chama o NextSample método .

Aplica-se a