You can delete performance counter categories when they are no longer needed. You can only delete categories that are not Windows-standard performance objects; that is, you can only delete categories that have been user-defined. You might delete a category if you have created a custom category associated with an application and you are removing that application from the system. For example, if you have an order entry application that creates counters in an OrderProcessing category, you would delete that category as part of uninstalling your application.
You use the DeleteCategory method to remove a category from the system. When you delete a category, all of the counters and instances associated with it are also removed.
Note You can also use the Delete method on the PerformanceCounterCategory class to remove a category. Both methods function identically, so use whichever class is most convenient for you.
It is important to note the difference between deleting a counter and deleting an instance of the PerformanceCounter component. When you use the Delete or DeleteCategory methods, you are deleting a category and its associated counters from the Windows operating system, rather than removing an instance of a counter from your project or application. When you delete an instance of the PerformanceCounter class, you remove a component that references an external counter.
To delete a category
Parameter | Value |
---|---|
CategoryName | The name of the category you want to delete. |
MachineName | (Optional) The computer on which the category you want to remove resides. If left blank, this parameter defaults to the local machine. |