InstanceData(String, CounterSample) 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
使用指定的样本和性能计数器实例来初始化 InstanceData 类的新实例。
public:
InstanceData(System::String ^ instanceName, System::Diagnostics::CounterSample sample);
public InstanceData (string instanceName, System.Diagnostics.CounterSample sample);
new System.Diagnostics.InstanceData : string * System.Diagnostics.CounterSample -> System.Diagnostics.InstanceData
Public Sub New (instanceName As String, sample As CounterSample)
参数
- instanceName
- String
与性能计数器关联的实例的名称。
- sample
- CounterSample
从 instanceName
参数指定的实例中采集的 CounterSample。
示例
下面的代码示例创建 InstanceData 并显示其某些字段的值。
// 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);
}
' Display the contents of an InstanceData object.
Sub ProcessInstanceDataObject(ByVal name As String, _
ByVal CSRef As CounterSample)
Dim instData As New InstanceData(name, CSRef)
Console.WriteLine(" Data from InstanceData object:" & vbCrLf & _
" InstanceName: {0,-31} RawValue: {1}", _
instData.InstanceName, instData.RawValue)
Dim sample As CounterSample = instData.Sample
Console.WriteLine(" Data from CounterSample object:" & vbCrLf & _
" CounterType: {0,-32} SystemFrequency: {1}" & vbCrLf & _
" BaseValue: {2,-34} RawValue: {3}" & vbCrLf & _
" CounterFrequency: {4,-27} CounterTimeStamp: {5}" & vbCrLf & _
" TimeStamp: {6,-34} TimeStamp100nSec: {7}", _
sample.CounterType, sample.SystemFrequency, sample.BaseValue, _
sample.RawValue, sample.CounterFrequency, sample.CounterTimeStamp, _
sample.TimeStamp, sample.TimeStamp100nSec)
End Sub