Exportar (0) Imprimir
Expandir todo

CounterCreationData.CounterName (Propiedad)

Obtiene o establece el nombre del contador personalizado.

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

public string CounterName { get; set; }
/** @property */
public String get_CounterName ()

/** @property */
public void set_CounterName (String value)

public function get CounterName () : String

public function set CounterName (value : String)

Valor de propiedad

Nombre del contador, que es único en su categoría.

Tipo de excepciónCondición

ArgumentNullException

El valor es referencia de objeto null (Nothing en Visual Basic).

ArgumentException

La longitud del valor especificado no está comprendida entre 1 y 80 caracteres o contiene comillas dobles, caracteres de control o espacios en blanco iniciales o finales.

using System;
using System.Diagnostics;

namespace MyDiagnostics
{
   class MyCounterCreationData
   {
      static void Main()
      {
         CounterCreationDataCollection myCol = 
                                    new CounterCreationDataCollection();

         // Create two custom counter objects.
         CounterCreationData myCounter1 = new CounterCreationData("Counter1",
            "First custom counter", PerformanceCounterType.CounterDelta32);

         CounterCreationData myCounter2 = new CounterCreationData();

         // Set the properties of the 'CounterCreationData' object.
         myCounter2.CounterName = "Counter2";
         myCounter2.CounterHelp = "Second custom counter";
         myCounter2.CounterType = PerformanceCounterType.NumberOfItemsHEX32;

         // Add custom counter objects to CounterCreationDataCollection.
         myCol.Add(myCounter1);
         myCol.Add(myCounter2);

         if (PerformanceCounterCategory.Exists("New Counter Category"))
            PerformanceCounterCategory.Delete("New Counter Category");

         // Bind the counters to a PerformanceCounterCategory.
         PerformanceCounterCategory myCategory = 
               PerformanceCounterCategory.Create("New Counter Category", "Category Help", myCol);

         Console.WriteLine("Counter Information:");
         Console.WriteLine("Category Name: " + myCategory.CategoryName);
         for (int i = 0; i < myCol.Count; i++)
         {
            // Display the properties of the CounterCreationData objects.
            Console.WriteLine("CounterName : " + myCol[i].CounterName);
            Console.WriteLine("CounterHelp : " + myCol[i].CounterHelp);
            Console.WriteLine("CounterType : " + myCol[i].CounterType);
         }
      }
   }
}

import System.*;
import System.Diagnostics.*;

class MyCounterCreationData
{
    public static void main(String[] args)
    {
        CounterCreationDataCollection myCol = new CounterCreationDataCollection();

        // Create two custom counter objects.
        CounterCreationData myCounter1 = 
            new CounterCreationData("Counter1", "First custom counter", 
            PerformanceCounterType.CounterDelta32);

        CounterCreationData myCounter2 = new CounterCreationData();

        // Set the properties of the 'CounterCreationData' object.
        myCounter2.set_CounterName("Counter2");
        myCounter2.set_CounterHelp("Second custom counter");
        myCounter2.set_CounterType(PerformanceCounterType.NumberOfItemsHEX32);

        // Add custom counter objects to CounterCreationDataCollection.
        myCol.Add(myCounter1);
        myCol.Add(myCounter2);
        if (PerformanceCounterCategory.Exists("New Counter Category")) {
            PerformanceCounterCategory.Delete("New Counter Category");
        }
        // Bind the counters to a PerformanceCounterCategory.
        PerformanceCounterCategory myCategory = 
            PerformanceCounterCategory.Create("New Counter Category", 
            "Category Help", myCol);

        Console.WriteLine("Counter Information:");
        Console.WriteLine("Category Name: " + myCategory.get_CategoryName());
        for (int i = 0; i < myCol.get_Count(); i++) {
            // Display the properties of the CounterCreationData objects.
            Console.WriteLine("CounterName : " 
                + myCol.get_Item(i).get_CounterName());
            Console.WriteLine("CounterHelp : " 
                + myCol.get_Item(i).get_CounterHelp());
            Console.WriteLine("CounterType : " 
                + myCol.get_Item(i).get_CounterType());
        }
    } //main
} //MyCounterCreationData

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center, Windows XP Professional x64, Windows XP SP2, Windows XP Starter Edition

.NET Framework no admite todas las versiones de cada plataforma. Para obtener una lista de las versiones admitidas, vea Requisitos del sistema.

.NET Framework

Compatible con: 2.0, 1.1, 1.0

Adiciones de comunidad

AGREGAR
Mostrar:
© 2014 Microsoft