本文整理匯總了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