Counters in C#

CsharpProgrammingServer Side Programming

Counters in C# are performance counters that lets you know about your applications performance.

When you will build an application, whether it is a web app, mobile app or even desktop app, you would definitely need to monitor the performance.

For performance counters in C#, use the System.Diagnostics.PerformanceCounter class. Set the instance of the PerformanceCounter class and work with the following properties: CategoryName, CounterName, MachineName and ReadOnly.

To get the performance categories.

var counter = PerformanceCounterCategory.GetCategories();

Now SET performance counters for the category processor.

var counter = PerformanceCounterCategory.GetCategories()
   .FirstOrDefault(category => category.CategoryName == "Processor");
raja
Updated on 30-Jul-2019 22:30:23

Advertisements