c# - Performance counters and threading -
i creating custom performance counters. creating tasks on thread pool , incrementing/decrementing counters within multiple worker threads.
do need give each thread new counter object? safe share performance counter object cross-thread (for increment/decrement)
the performancecounter class uses threadsafe wrapper, internal class named sharedperformancecounter. uses interlocked.increment() increment counter value example.
there's no need lock yourself.
Comments
Post a Comment