InstanceData.Sample Property


Gets the performance counter sample that generated this data.

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

public CounterSample Sample { get; }

Property Value

Type: System.Diagnostics.CounterSample

A CounterSample taken from the instance specified by the InstanceName property.

The following code example creates an InstanceData and gets the value of its Sample property, which is a reference to a CounterSample. The example then displays the fields of the CounterSample.

// Display the contents of an InstanceData object.
public static void ProcessInstanceDataObject(string name, CounterSample CSRef)

    InstanceData instData = new InstanceData(name, CSRef);
    Console.WriteLine("    Data from InstanceData object:\r\n" +
        "      InstanceName: {0,-31} RawValue: {1}", instData.InstanceName, instData.RawValue);

    CounterSample sample = instData.Sample;
    Console.WriteLine("    Data from CounterSample object:\r\n" +
        "      CounterType: {0,-32} SystemFrequency: {1}\r\n" +
        "      BaseValue: {2,-34} RawValue: {3}\r\n" +
        "      CounterFrequency: {4,-27} CounterTimeStamp: {5}\r\n" +
        "      TimeStamp: {6,-34} TimeStamp100nSec: {7}", sample.CounterType, sample.SystemFrequency, sample.BaseValue, sample.RawValue, sample.CounterFrequency, sample.CounterTimeStamp, sample.TimeStamp, sample.TimeStamp100nSec);

.NET Framework
Available since 1.1
Return to top