diff --git a/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs b/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs index 25540b40a10..6103ba99aab 100644 --- a/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs @@ -104,20 +104,16 @@ namespace Grpc.Core.Internal private void BeginOp() { - if (shutdownRefcount != null) - { - bool success = false; - shutdownRefcount.IncrementIfNonzero(ref success); - GrpcPreconditions.CheckState(success, "Shutdown has already been called"); - } + GrpcPreconditions.CheckNotNull(shutdownRefcount, nameof(shutdownRefcount)); + bool success = false; + shutdownRefcount.IncrementIfNonzero(ref success); + GrpcPreconditions.CheckState(success, "Shutdown has already been called"); } private void EndOp() { - if (shutdownRefcount != null) - { - DecrementShutdownRefcount(); - } + GrpcPreconditions.CheckNotNull(shutdownRefcount, nameof(shutdownRefcount)); + DecrementShutdownRefcount(); } // Allows declaring BeginOp and EndOp of a completion queue with a using statement.