Avoid race condition in DiagnosticCounter (dotnet/coreclr#26260)
authorStephen Toub <stoub@microsoft.com>
Tue, 20 Aug 2019 19:21:27 +0000 (15:21 -0400)
committerGitHub <noreply@github.com>
Tue, 20 Aug 2019 19:21:27 +0000 (15:21 -0400)
commita96524beb7644569124cf72d52f76d5e57151f83
tree475c1a60199f8b190f4c892ad5fbe4cff4c2649a
parentf1516bbf1361c769e89e3904af5d7af658234fec
Avoid race condition in DiagnosticCounter (dotnet/coreclr#26260)

* Avoid race condition in DiagnosticCounter

If while a DiagnosticCounter instance is being created the timer fires to process counters, the timer may end up evaluating a DiagnosticCounter whose constructor or derived types' constructor hasn't finished configuring the instance's state yet.

* Remove unnecessary #if

Commit migrated from https://github.com/dotnet/coreclr/commit/5ae4f6d650b001f61961316206b373c9c71e5fe5
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/DiagnosticCounter.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventCounter.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingEventCounter.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingPollingCounter.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/PollingCounter.cs