# PerformanceCounter

The Wisej.NET `PerformanceCounter` component enables reading predefined or custom performance counters and publishing data to custom counters through Windows Performance Monitor.

{% hint style="info" %}
The `PerformanceCounter` implements `IDisposable`. Always dispose of it either:

* Directly: Call `Dispose()` in a try/catch block
* Indirectly: Use language constructs like `using` (C#) or `Using` (VB)
  {% endhint %}

## Features

### Counter Types

Two main usage scenarios:

* Read existing predefined or custom counters
* Publish (write) performance data to custom counters

### Predefined Counters

Access numerous predefined counters through Windows Performance Monitor's [Add Counters dialog box](https://go.microsoft.com/fwlink/p/?LinkId=257854).

{% hint style="info" %}
For detailed information about performance monitoring, see:

* [.NET Framework Performance Counters](https://docs.microsoft.com/en-us/dotnet/framework/debug-trace-profile/performance-counters)
* [System.Diagnostics.PerformanceCounter on MSDN](https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.performancecounter?view=net-5.0)
* [Using Objects that Implement IDisposable](https://docs.microsoft.com/en-us/dotnet/api/system.idisposable?view=net-5.0)
  {% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/docs/controls/other-components/performancecounter.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
