CounterCreationDataCollection Constructor (CounterCreationDataCollection)
.NET Framework (current version)
![]() |
---|
The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience. |
Initializes a new instance of the CounterCreationDataCollection class by using the specified collection of CounterCreationData instances.
Assembly: System (in System.dll)
Parameters
- value
-
Type:
System.Diagnostics.CounterCreationDataCollection
A CounterCreationDataCollection that holds CounterCreationData instances with which to initialize this CounterCreationDataCollection.
Exception | Condition |
---|---|
ArgumentNullException | value is null. |
The following example demonstrates how to create a CounterCreationDataCollection object by using CounterCreationData objects from another CounterCreationDataCollection.
Dim myCategoryName As String Dim numberOfCounters As Integer Console.Write("Enter the number of counters : ") numberOfCounters = Integer.Parse(Console.ReadLine()) Dim myCounterCreationData(numberOfCounters - 1) As CounterCreationData Dim i As Integer For i = 0 To numberOfCounters - 1 Console.Write("Enter the counter name for {0} counter : ", i) myCounterCreationData(i) = New CounterCreationData() myCounterCreationData(i).CounterName = Console.ReadLine() Next i Dim myCounterCollection As New CounterCreationDataCollection(myCounterCreationData) Console.Write("Enter the category Name:") myCategoryName = Console.ReadLine() ' Check if the category already exists or not. If Not PerformanceCounterCategory.Exists(myCategoryName) Then Dim myNewCounterCollection As New CounterCreationDataCollection(myCounterCollection) PerformanceCounterCategory.Create(myCategoryName, "Sample Category", _ PerformanceCounterCategoryType.SingleInstance, myNewCounterCollection) Console.WriteLine("The list of counters in 'CounterCollection' are : ") For i = 0 To myNewCounterCollection.Count - 1 Console.WriteLine("Counter {0} is '{1}'", i, myNewCounterCollection(i).CounterName) Next i Else Console.WriteLine("The category already exists") End If
.NET Framework
Available since 1.1
Available since 1.1
Show: