SystemMonitor ActiveX control and custom performance counters

  • Thread starter Thread starter Ivan
  • Start date Start date
I

Ivan

I have the SystemMonitor ActiveX control on a form and I try to register a custom performance counter.
I expect that after registering the counter with the OS, the user would be able to add it through
this System Monitor ActiveX control on the form.
Yet, the Add dialog of this ActiveX does NOT contain the already registered counter.
Does anyone know what might be wrong?
Code snippet follows at the end.
BTW if I have the code that registers the counter in a separate executable, then the ActiveX has my
counter. But if they're in one and the same executable, the ActiveX doesn't have it !?!

Ivan



using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Diagnostics;

namespace WindowsApplication1
{
public class Form1 : System.Windows.Forms.Form
{
private AxSystemMonitor.AxSystemMonitor axSystemMonitor1;
private System.ComponentModel.Container components = null;

[STAThread]
static void Main()
{
CounterCreationDataCollection CCDC = new CounterCreationDataCollection();
CounterCreationData ccd = new CounterCreationData(
"MyCounterName",
"Some Help",
PerformanceCounterType.NumberOfItems32
);
CCDC.Add( ccd );
if (PerformanceCounterCategory.Exists("MyCategoryName") )
PerformanceCounterCategory.Delete("MyCategoryName");
PerformanceCounterCategory.Create("MyCategoryName", "Some Help", CCDC);

Application.Run(new Form1());
}

public Form1()
{
InitializeComponent();
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.axSystemMonitor1 = new AxSystemMonitor.AxSystemMonitor();
((System.ComponentModel.ISupportInitialize)(this.axSystemMonitor1)).BeginInit();
this.SuspendLayout();
this.axSystemMonitor1.Enabled = true;
this.axSystemMonitor1.Location = new System.Drawing.Point(0, 0);
this.axSystemMonitor1.Name = "axSystemMonitor1";
this.axSystemMonitor1.OcxState =
((System.Windows.Forms.AxHost.State)(resources.GetObject("axSystemMonitor1.OcxState")));
this.axSystemMonitor1.Size = new System.Drawing.Size(328, 272);
this.axSystemMonitor1.TabIndex = 0;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(344, 269);
this.Controls.Add(this.axSystemMonitor1);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.axSystemMonitor1)).EndInit();
this.ResumeLayout(false);

}
#endregion
}
}
 
Back
Top