InstanceData Constructor (String, CounterSample)


Initializes a new instance of the InstanceData class, using the specified sample and performance counter instance.

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

public InstanceData(
	string instanceName,
	CounterSample sample


Type: System.String

The name of an instance associated with the performance counter.

Type: System.Diagnostics.CounterSample

A CounterSample taken from the instance specified by the instanceName parameter.

The following code example creates an InstanceData and displays the values of some of its fields.

// 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