Performance Counters and Threads

I am creating some custom performance counters. I will create tasks in the thread pool and increase / decrease counters from several worker threads.

Do I need to give each thread a new counter object? Is it safe to split the end-to-end flow of the performance counter object (to increase / decrease)

+7
c #
source share
1 answer

The PerformanceCounter class already uses a thread-safe wrapper, an inner class called SharedPerformanceCounter. It uses Interlocked.Increment () to increment a counter value, for example.

No need to block yourself.

+6
source share

All Articles