Export (0) Print
Expand All

PerformanceCounterInstaller Class

Specifies an installer for the PerformanceCounter component.

Namespace: System.Diagnostics
Assembly: System.Configuration.Install (in system.configuration.install.dll)

public class PerformanceCounterInstaller : ComponentInstaller
public class PerformanceCounterInstaller extends ComponentInstaller
public class PerformanceCounterInstaller extends ComponentInstaller

The following information might help provide a performance improvement when installing performance counters at application startup. Performance counter categories installed with .NET Framework version 2.0 use separate shared memories, with each performance counter category having its own memory. You can specify the size of separate shared memory by creating a DWORD registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<category name>\Performance\FileMappingSize with a value such as 131072, the current default. If the registry key is not present, the fileMappingSize attribute value for the performanceCounters element specified in the machine.config file is used, causing additional overhead for configuration file processing. You can realize a performance improvement for application startup by the use of the registry key.

using System;
using System.Configuration.Install;
using System.Diagnostics;
using System.ComponentModel;

[RunInstaller(true)]
public class MyPerformanceCounterInstaller: Installer
{
   public MyPerformanceCounterInstaller()
   {
      try
      {
         // Create an instance of 'PerformanceCounterInstaller'.
         PerformanceCounterInstaller myPerformanceCounterInstaller =
            new PerformanceCounterInstaller();
         // Set the 'CategoryName' for performance counter.
         myPerformanceCounterInstaller.CategoryName =
            "MyPerformanceCounter";
         CounterCreationData myCounterCreation = new CounterCreationData();
         myCounterCreation.CounterName = "MyCounter";
         myCounterCreation.CounterHelp = "Counter Help";
         // Add a counter to collection of  myPerformanceCounterInstaller.
         myPerformanceCounterInstaller.Counters.Add(myCounterCreation);
         Installers.Add(myPerformanceCounterInstaller);
      }
      catch(Exception e)
      {
         Console.WriteLine("Error occured :"+e.Message);
      }
   }
   public static void Main()
   {
   }
}

import System.*;
import System.Configuration.Install.*;
import System.Diagnostics.*;
import System.ComponentModel.*;

/** @attribute RunInstaller(true)
 */
public class MyPerformanceCounterInstaller extends Installer
{
    public MyPerformanceCounterInstaller()
    {
        try {
            // Create an instance of 'PerformanceCounterInstaller'.
            PerformanceCounterInstaller myPerformanceCounterInstaller =
                new PerformanceCounterInstaller();
            // Set the 'CategoryName' for performance counter.
            myPerformanceCounterInstaller.set_CategoryName(
                "MyPerformanceCounter");
            CounterCreationData myCounterCreation = 
                new CounterCreationData();
            myCounterCreation.set_CounterName("MyCounter");
            myCounterCreation.set_CounterHelp("Counter Help");
            // Add a counter to collection of  myPerformanceCounterInstaller.
            myPerformanceCounterInstaller.get_Counters().Add(myCounterCreation);
            InstallerCollection installers = null;
            installers.Add(myPerformanceCounterInstaller);
        }
        catch (System.Exception e) {
            Console.WriteLine("Error occured :" + e.get_Message());
        }
    } //MyPerformanceCounterInstaller

    public static void main(String[] args)
    {
    } //main
} //MyPerformanceCounterInstaller

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft