diff --git a/src/csharp/Grpc.IntegrationTesting/Histogram.cs b/src/csharp/Grpc.IntegrationTesting/Histogram.cs index 0a294dde02f..7e7cb2c4de0 100644 --- a/src/csharp/Grpc.IntegrationTesting/Histogram.cs +++ b/src/csharp/Grpc.IntegrationTesting/Histogram.cs @@ -52,8 +52,7 @@ namespace Grpc.IntegrationTesting /// public class Histogram { - readonly SpinLock spinlock = new SpinLock(); - + readonly object myLock = new object(); readonly double multiplier; readonly double oneOnLogMultiplier; readonly double maxPossible; @@ -79,16 +78,10 @@ namespace Grpc.IntegrationTesting public void AddObservation(double value) { - bool lockTaken = false; - spinlock.Enter(ref lockTaken); - try + lock (myLock) { AddObservationUnsafe(value); } - finally - { - if (lockTaken) spinlock.Exit(); - } } @@ -97,16 +90,10 @@ namespace Grpc.IntegrationTesting /// public HistogramData GetSnapshot(bool reset = false) { - bool lockTaken = false; - spinlock.Enter(ref lockTaken); - try + lock (myLock) { return GetSnapshotUnsafe(reset); } - finally - { - if (lockTaken) spinlock.Exit(); - } } ///