Sdílet prostřednictvím


InstanceDataCollectionCollection.Keys Vlastnost

Definice

Získá objekt a klíče registru čítače pro objekty přidružené k této kolekci dat instance.

public:
 property System::Collections::ICollection ^ Keys { System::Collections::ICollection ^ get(); };
public System.Collections.ICollection Keys { get; }
member this.Keys : System.Collections.ICollection
Public ReadOnly Property Keys As ICollection

Hodnota vlastnosti

Představuje ICollection sadu klíčů registru specifických pro objekty.

Příklady

Následující příklad kódu používá Keys vlastnost vrácení InstanceDataCollectionCollection kolekce názvů čítačů, který převede na pole String. Generuje pole InstanceDataCollection objektů pomocí Values vlastnosti. Pro každý prvek v poli názvů čítačů zobrazí název a zavolá funkci pro zpracování přidružené InstanceDataCollection.


// Process the InstanceDataCollectionCollection for this category.
PerformanceCounterCategory pcc = new PerformanceCounterCategory(categoryName);
InstanceDataCollectionCollection idColCol = pcc.ReadCategory();

ICollection idColColKeys = idColCol.Keys;
string[] idCCKeysArray = new string[idColColKeys.Count];
idColColKeys.CopyTo(idCCKeysArray, 0);

ICollection idColColValues = idColCol.Values;
InstanceDataCollection[] idCCValuesArray = new InstanceDataCollection[idColColValues.Count];
idColColValues.CopyTo(idCCValuesArray, 0);

Console.WriteLine("InstanceDataCollectionCollection for \"{0}\" " +
    "has {1} elements.", categoryName, idColCol.Count);

// Display the InstanceDataCollectionCollection Keys and Values.
// The Keys and Values collections have the same number of elements.
int index;
for(index=0; index<idCCKeysArray.Length; index++)
{
    Console.WriteLine("  Next InstanceDataCollectionCollection " +
        "Key is \"{0}\"", idCCKeysArray[index]);
    ProcessInstanceDataCollection(idCCValuesArray[index]);
}

' Process the InstanceDataCollectionCollection for this category.
Dim pcc As New PerformanceCounterCategory(categoryName)
Dim idColCol As InstanceDataCollectionCollection = pcc.ReadCategory()

Dim idColColKeys As ICollection = idColCol.Keys
Dim idCCKeysArray(idColColKeys.Count - 1) As String
idColColKeys.CopyTo(idCCKeysArray, 0)

Dim idColColValues As ICollection = idColCol.Values
Dim idCCValuesArray(idColColValues.Count - 1) As InstanceDataCollection
idColColValues.CopyTo(idCCValuesArray, 0)

Console.WriteLine("InstanceDataCollectionCollection for ""{0}"" " & _
    "has {1} elements.", categoryName, idColCol.Count)

' Display the InstanceDataCollectionCollection Keys and Values.
' The Keys and Values collections have the same number of elements.
Dim index As Integer
For index = 0 To idCCKeysArray.Length - 1
    Console.WriteLine("  Next InstanceDataCollectionCollection " & _
        "Key is ""{0}""", idCCKeysArray(index))
    ProcessInstanceDataCollection(idCCValuesArray(index))
Next index

Poznámky

Každá softwarová komponenta vytváří klíče pro své objekty a čítače při instalaci a zapisuje data čítačů během provádění. K datům můžete přistupovat stejně jako k jiným datům registru. I když ale registr používáte ke shromažďování údajů o výkonu, data nejsou uložená v databázi registru. Místo toho systém shromažďuje data od příslušných správců systémových objektů.

Platí pro