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

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

Namespace:  System.Diagnostics
Assembly:  System (in System.dll)

public CounterSample(
	long rawValue,
	long baseValue,
	long counterFrequency,
	long systemFrequency,
	long timeStamp,
	long timeStamp100nSec,
	PerformanceCounterType counterType,
	long counterTimeStamp
)

Parameters

rawValue
Type: System.Int64
The numeric value associated with the performance counter sample.
baseValue
Type: System.Int64
An optional, base raw value for the counter, to use only if the sample is based on multiple counters.
counterFrequency
Type: System.Int64
The frequency with which the counter is read.
systemFrequency
Type: System.Int64
The frequency with which the system reads from the counter.
timeStamp
Type: System.Int64
The raw time stamp.
timeStamp100nSec
Type: System.Int64
The raw, high-fidelity time stamp.
counterType
Type: System.Diagnostics.PerformanceCounterType
A PerformanceCounterType object that indicates the type of the counter for which this sample is a snapshot.
counterTimeStamp
Type: System.Int64
The time at which the sample was taken.

Use this constructor to take samples after you have already taken an initial sample of the performance counter. The System Monitor supplies values for these parameters automatically when you call the NextSample method.

The following example demonstrates how to initialize a new CounterSample structure, passing in values for the rawValue, baseValue, counterFrequency, systemFrequency, timeStamp, timeStamp100nSec, counterType, and counterTimeStamp parameters. After creating the CounterSample structure, the example displays the property values for the CounterSample in the console window.


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


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2015 Microsoft