Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4342562
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:38:04+00:00 2026-05-21T11:38:04+00:00

I have added performance custom counters to my application to whether the no of

  • 0

I have added performance custom counters to my application to
whether the no of times the operation takes place or not .

But now I want to unregister it .
Is it possible to unregister it remove it .

I have used this counters in C#.

The class which creates a performance category and
adds counters to it .

using System;
using System.Diagnostics;

namespace GroupChatLibrarySamples
{
    ///<summary>
    ///Helper class to demonstrate the setup of performance counters.
    ///</summary>
    public class PerformanceCounterHelper
    {
        //Total number of tests executed
        private PerformanceCounter _TotalFiles = null;
        /// <summary>
        /// Constructor
        /// </summary>
        public PerformanceCounterHelper()
        {
            // Set up the performance counter(s)
             if (!PerformanceCounterCategory.Exists("Total_Files","."))
             {
                //Create the collection container
                CounterCreationDataCollection counters = new CounterCreationDataCollection();
                ////Create counter #1 and add it to the collection
                CounterCreationData tests = new CounterCreationData();
                tests.CounterName = "Total_Files_Sent";
                tests.CounterHelp = "Total number of Files Sent";
                tests.CounterType = PerformanceCounterType.NumberOfItems32;
                counters.Add(tests);

                //Create the category and all of the counters.
                PerformanceCounterCategory.Create("Total_Files", "Performance Counter for checking no of files sent", counters);
             }
             try
             {
                 _TotalFiles = new PerformanceCounter();
                 _TotalFiles.CategoryName = "Total_Files";
                 _TotalFiles.CounterName = "Total_Files_Sent";
                 _TotalFiles.MachineName = ".";
                 _TotalFiles.ReadOnly = false;
             }
             catch (Exception e)
             {
                 Console.WriteLine(" {0} \n", e.StackTrace);

             }

        }


        public void IncrementCounters()
        {
            _TotalFiles.Increment();

        }
    }
}

The code where counter is incremented :

    private void BeginSendFilesFinished(IAsyncResult ar) 
    {

        currentOperation.End("BeginSendFilesFinished", () => session.EndUploadFile(ar)); 
        Console.WriteLine(" File Count  : {0} \n", listoffiles.Count);
        if(sentFiles <  (listoffiles.Count-1))
        {
                sentFiles++;  
                string SampleFile = listoffiles[sentFiles].ToString();
                FileInfo filetoupload = new FileInfo(SampleFile);                        
                ChatRoomFileUploadJob uploadfilejob = new ChatRoomFileUploadJob(filetoupload);
                counterHelper.IncrementCounters();   
                currentOperation.Begin(string.Format("Send Files: # {0}", sentFiles), () => session.BeginUploadFile(uploadfilejob, BeginSendFilesFinished, null));

        }
        else
        {
            Log("Leave ChatRoom:");
            // After sending 10 chat msgs, leave the chat room (and rejoin).
            currentOperation.Begin("Leave ChatRoom:", () => session.BeginLeave(BeginLeaveChatRoomFinished, null));
        }
    }

Thanks & Regards,
Tazim.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T11:38:05+00:00Added an answer on May 21, 2026 at 11:38 am

    This might be too obvious, but given that you’re trying to do the opposite of the PerformanceCounterCategory.Create action (I think), have you looked at using PerformanceCounterCategory.Delete? According to the documentation it:

    Removes the category and its
    associated counters from the local
    computer

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have designed a class which is basically nothing but an object which stores
I am trying to get a better understanding about insertion speed and performance patterns
I have been using VS2010 with Resharper 5 for several weeks and am having
I have quite a complicated ListView . Each item looks something like this: >
I have a data class Student, and I have an aggregate class Students. Student
I have used the Eclipse plugin Visual Editor to construct Java Swing interfaces. As
Say I have a table of apples (apple_id). And for each apple I have
We have a data grid on a window that is bound to a collection
I have a set of model objects that have a public IsVisible boolean property.
Each product a product_date_added which is a Date field contained the date it was

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.