This documentation is archived and is not being maintained.

CounterSample Constructor

.NET Framework 1.1

Initializes a new instance of the CounterSample class.

Overload List

Initializes a new instance of the CounterSample class and sets the CounterTimeStamp property to zero (0).

[Visual Basic] Public Sub New(Long, Long, Long, Long, Long, Long, PerformanceCounterType)
[C#] public CounterSample(long, long, long, long, long, long, PerformanceCounterType);
[C++] public: CounterSample(__int64, __int64, __int64, __int64, __int64, __int64, PerformanceCounterType);
[JScript] public function CounterSample(long, long, long, long, long, long, PerformanceCounterType);

Initializes a new instance of the CounterSample class and sets the CounterTimeStamp property to the value passed in.

[Visual Basic] Public Sub New(Long, Long, Long, Long, Long, Long, PerformanceCounterType, Long)
[C#] public CounterSample(long, long, long, long, long, long, PerformanceCounterType, long);
[C++] public: CounterSample(__int64, __int64, __int64, __int64, __int64, __int64, PerformanceCounterType, __int64);
[JScript] public function CounterSample(long, long, long, long, long, long, PerformanceCounterType, long);

Example

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of the CounterSample constructor. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
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)

[C#] 
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);

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

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

CounterSample Structure | CounterSample Members | System.Diagnostics Namespace

Show: