PerformanceCounterInstaller Class

Specifies an installer for the PerformanceCounter component.

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

'Declaration
Public Class PerformanceCounterInstaller
	Inherits ComponentInstaller
'Usage
Dim instance As PerformanceCounterInstaller

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.

Imports System
Imports System.Configuration.Install
Imports System.Diagnostics
Imports System.ComponentModel

<RunInstaller(True)>  _
Public Class MyPerformanceCounterInstaller
   Inherits Installer
   Public Sub New()
      Try
         ' Create an instance of 'PerformanceCounterInstaller'.
         Dim myPerformanceCounterInstaller As New PerformanceCounterInstaller()
         ' Set the 'CategoryName' for performance counter.
         myPerformanceCounterInstaller.CategoryName = "MyPerformanceCounter"
         Dim myCounterCreation As New CounterCreationData()
         myCounterCreation.CounterName = "MyCounter"
         myCounterCreation.CounterHelp = "Counter Help"
         ' Add a counter to collection of  myPerformanceCounterInstaller.
         myPerformanceCounterInstaller.Counters.Add(myCounterCreation)
         Installers.Add(myPerformanceCounterInstaller)
      Catch e As Exception
         Console.WriteLine("Error occured :" + e.Message)
      End Try
   End Sub 'New
   Public Shared Sub Main()
   End Sub 'Main
End Class 'MyPerformanceCounterInstaller

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: