CounterCreationDataCollection (Constructor) (CounterCreationDataCollection)
Collapse the table of content
Expand the table of content

CounterCreationDataCollection (Constructor) (CounterCreationDataCollection)

Inicializa una nueva instancia de la clase CounterCreationDataCollection utilizando la colección especificada de instancias de CounterCreationData.

Espacio de nombres: System.Diagnostics
Ensamblado: System (en system.dll)

public CounterCreationDataCollection (
	CounterCreationDataCollection value
)
public CounterCreationDataCollection (
	CounterCreationDataCollection value
)
public function CounterCreationDataCollection (
	value : CounterCreationDataCollection
)
No aplicable.

Parámetros

value

CounterCreationDataCollection que contiene las instancias de CounterCreationData con las que inicializar CounterCreationDataCollection.

Tipo de excepciónCondición

ArgumentNullException

value es referencia null (Nothing en Visual Basic).

String^ myCategoryName;
int numberOfCounters;
Console::Write( "Enter the number of counters : " );
numberOfCounters = Int32::Parse( Console::ReadLine() );
array<CounterCreationData^>^myCounterCreationData = gcnew array<CounterCreationData^>(numberOfCounters);
for ( int i = 0; i < numberOfCounters; i++ )
{
   Console::Write( "Enter the counter name for {0} counter : ", i );
   myCounterCreationData[ i ] = gcnew CounterCreationData;
   myCounterCreationData[ i ]->CounterName = Console::ReadLine();

}
CounterCreationDataCollection^ myCounterCollection = gcnew CounterCreationDataCollection( myCounterCreationData );
Console::Write( "Enter the category Name:" );
myCategoryName = Console::ReadLine();

// Check if the category already exists or not.
if (  !PerformanceCounterCategory::Exists( myCategoryName ) )
{
   CounterCreationDataCollection^ myNewCounterCollection = gcnew CounterCreationDataCollection( myCounterCollection );
   PerformanceCounterCategory::Create( myCategoryName, "Sample Category", myNewCounterCollection );
   for ( int i = 0; i < numberOfCounters; i++ )
   {
      myCounter = gcnew PerformanceCounter( myCategoryName,myCounterCreationData[ i ]->CounterName,"",false );

   }
   Console::WriteLine( "The list of counters in 'CounterCollection' are : " );
   for ( int i = 0; i < myNewCounterCollection->Count; i++ )
      Console::WriteLine( "Counter {0} is '{1}'", i, myNewCounterCollection[ i ]->CounterName );
}
else
{
   Console::WriteLine( "The category already exists" );
}

String myCategoryName;
int numberOfCounters;
Console.Write("Enter the number of counters : ");
numberOfCounters = Int32.Parse(Console.ReadLine());
CounterCreationData myCounterCreationData[] = new 
    CounterCreationData[numberOfCounters];
for (int i = 0; i < numberOfCounters; i++) {
    Console.Write("Enter the counter name for {0} counter : ",
        System.Convert.ToString(i));
    myCounterCreationData.set_Item(i, new CounterCreationData());
    myCounterCreationData[i].set_CounterName(Console.ReadLine());
}
CounterCreationDataCollection myCounterCollection = new 
    CounterCreationDataCollection(myCounterCreationData);
Console.Write("Enter the category Name:");
myCategoryName = Console.ReadLine();
// Check if the category already exists or not.
if (!(PerformanceCounterCategory.Exists(myCategoryName))) {
    CounterCreationDataCollection myNewCounterCollection = new
        CounterCreationDataCollection(myCounterCollection);
    PerformanceCounterCategory.Create(myCategoryName, 
        "Sample Category", myNewCounterCollection);

    for (int i = 0; i < numberOfCounters; i++) {
        myCounter = new PerformanceCounter(myCategoryName,
            myCounterCreationData[i].get_CounterName(), "", false);
    }
    Console.WriteLine("The list of counters in "
        + "'CounterCollection' are : ");
    for (int i = 0; i < myNewCounterCollection.get_Count(); i++) {
        Console.WriteLine("Counter {0} is '{1}'", 
            System.Convert.ToString(i), 
            myNewCounterCollection.get_Item(i).get_CounterName());
    }
}
else {
    Console.WriteLine("The category already exists");
}

String myCategoryName;
int numberOfCounters;
Console.Write("Enter the number of counters : ");
numberOfCounters = Int32.Parse(Console.ReadLine());
CounterCreationData myCounterCreationData[] = new 
    CounterCreationData[numberOfCounters];
for (int i = 0; i < numberOfCounters; i++) {
    Console.Write("Enter the counter name for {0} counter : ",
        System.Convert.ToString(i));
    myCounterCreationData[i] = new CounterCreationData();
    myCounterCreationData[i].set_CounterName(Console.ReadLine());
}
CounterCreationDataCollection myCounterCollection = new 
    CounterCreationDataCollection(myCounterCreationData);
Console.Write("Enter the category Name:");
myCategoryName = Console.ReadLine();
// Check if the category already exists or not.
if (!(PerformanceCounterCategory.Exists(myCategoryName))) {
    CounterCreationDataCollection myNewCounterCollection = new 
        CounterCreationDataCollection(myCounterCollection);
    PerformanceCounterCategory.Create(myCategoryName,
        "Sample Category", myNewCounterCollection);

    for (int i = 0; i < numberOfCounters; i++) {
        myCounter = new PerformanceCounter(myCategoryName, 
            myCounterCreationData[i].get_CounterName(), "", false);
    }
    Console.WriteLine("The list of counters in "
        + "'CounterCollection' are : ");
    for (int i = 0; i < myNewCounterCollection.get_Count(); i++) {
        Console.WriteLine("Counter {0} is '{1}'", 
            System.Convert.ToString(i), 
            myNewCounterCollection.get_Item(i).get_CounterName());
    }
}
else {
    Console.WriteLine("The category already exists");
}

Windows 98, Windows 2000 Service Pack 4, Windows Millennium, Windows Server 2003, Windows XP Media Center, Windows XP Professional x64, Windows XP SP2, Windows XP Starter

Microsoft .NET Framework 3.0 es compatible con Windows Vista, Microsoft Windows XP SP2 y Windows Server 2003 SP1.

.NET Framework

Compatible con: 3.0, 2.0, 1.1, 1.0

Adiciones de comunidad

AGREGAR
Mostrar:
© 2016 Microsoft