本文整理汇总了VB.NET中System.Diagnostics.InstanceDataCollectionCollection.Item属性的典型用法代码示例。如果您正苦于以下问题:VB.NET InstanceDataCollectionCollection.Item属性的具体用法?VB.NET InstanceDataCollectionCollection.Item怎么用?VB.NET InstanceDataCollectionCollection.Item使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Diagnostics.InstanceDataCollectionCollection
的用法示例。
在下文中一共展示了InstanceDataCollectionCollection.Item属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Main
Sub Main(ByVal args() As String)
Dim categoryName As String = ""
Dim counterName As String = ""
Dim idColCol As InstanceDataCollectionCollection
' Copy the supplied arguments into the local variables.
Try
categoryName = args(0)
counterName = args(1)
Catch ex As Exception
' Ignore the exception from non-supplied arguments.
End Try
Try
' Get the InstanceDataCollectionCollection for this category.
Dim pcc As New PerformanceCounterCategory(categoryName)
idColCol = pcc.ReadCategory()
Catch ex As Exception
Console.WriteLine( _
"An error occurred getting the InstanceDataCollection for " & _
"category ""{0}""." & vbCrLf & ex.Message, categoryName)
Return
End Try
' Check if this counter name exists using the Contains
' method of the InstanceDataCollectionCollection.
If Not idColCol.Contains(counterName) Then
Console.WriteLine( _
"Counter ""{0}"" does not exist in category ""{1}"".", _
counterName, categoryName)
Return
Else
' Now get the counter's InstanceDataCollection object using the
' indexer (Item property) for the InstanceDataCollectionCollection.
Dim countData As InstanceDataCollection = idColCol(counterName)
Dim idColKeys As ICollection = countData.Keys
Dim idColKeysArray(idColKeys.Count - 1) As String
idColKeys.CopyTo(idColKeysArray, 0)
Console.WriteLine("Counter ""{0}"" of category ""{1}"" " & _
"has {2} instances.", counterName, categoryName, idColKeys.Count)
' Display the instance names for this counter.
Dim index As Integer
For index = 0 To idColKeysArray.Length - 1
Console.WriteLine("{0,4} -- {1}", index + 1, idColKeysArray(index))
Next index
End If
End Sub