From 91c1a4ecfed3dc38436a87eb8c56df50df657391 Mon Sep 17 00:00:00 2001 From: Steve Harter Date: Thu, 24 Apr 2025 13:45:42 -0500 Subject: [PATCH] Remove a couple unnecessary 'lock(this)' statements --- .../Diagnostics/PerformanceCounterCategory.cs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/PerformanceCounterCategory.cs b/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/PerformanceCounterCategory.cs index c5f56ddc6ea94a..3b12c9014e4590 100644 --- a/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/PerformanceCounterCategory.cs +++ b/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/PerformanceCounterCategory.cs @@ -73,12 +73,7 @@ public string CategoryName if (value.Length == 0) throw new ArgumentException(SR.Format(SR.InvalidProperty, nameof(CategoryName), value), nameof(value)); - // the lock prevents a race between setting CategoryName and MachineName, since this permission - // checks depend on both pieces of info. - lock (this) - { - _categoryName = value; - } + _categoryName = value; } } @@ -136,12 +131,7 @@ public string MachineName if (!SyntaxCheck.CheckMachineName(value)) throw new ArgumentException(SR.Format(SR.InvalidProperty, nameof(MachineName), value), nameof(value)); - // the lock prevents a race between setting CategoryName and MachineName, since this permission - // checks depend on both pieces of info. - lock (this) - { - _machineName = value; - } + _machineName = value; } }