Delete instance by name

May 22, 2013 at 11:35 AM
Hi

I am looking on using your helper class in a web site. since IIS is recycling by starting a new instance of the application while the previous application is still running, you created the instance name as assembly_process_id
this works great but previous instances are shown as existing instances in the performance monitoring. as the old instance is not deleted.

please add a DeleteInstance(instanceName) method

this way my code will work like this:
on the IIS event ApplicationStart I will create an instance of a static class that will hold the performance counters
the site will access the static class and will update counters as needed
when IIS fires the ApplicationEnd event, I will call the new DeleteInstance method to delete the instances and then dispose of the static instance



besides that a small bug in your code:
the multi instance form is missing the counter installation on the form_load (the whole if statement is missing)
    private void MainForm_Load(object sender, EventArgs e)
    {
        counterHelper = PerformanceHelper.CreateCounterHelper<MultiInstance_PerformanceCounters>();
       if (counterHelper == null)
        {
            MessageBox.Show("Counter not installed. Attempting to install.");
            PerformanceHelper.Install(typeof(MultiInstance_PerformanceCounters));
        }

    }