diff --git a/src/MongoDB.Driver/Core/Connections/BinaryConnection.cs b/src/MongoDB.Driver/Core/Connections/BinaryConnection.cs index b2f35c6da36..2832cae67b9 100644 --- a/src/MongoDB.Driver/Core/Connections/BinaryConnection.cs +++ b/src/MongoDB.Driver/Core/Connections/BinaryConnection.cs @@ -543,6 +543,7 @@ public async Task ReceiveMessageAsync(OperationContext operatio private void SendBuffer(OperationContext operationContext, IByteBuffer buffer) { + ThrowIfCancelledOrDisposed(operationContext); _sendLock.Wait(operationContext.RemainingTimeout, operationContext.CancellationToken); try { @@ -571,6 +572,7 @@ private void SendBuffer(OperationContext operationContext, IByteBuffer buffer) private async Task SendBufferAsync(OperationContext operationContext, IByteBuffer buffer) { + ThrowIfCancelledOrDisposed(operationContext); await _sendLock.WaitAsync(operationContext.RemainingTimeout, operationContext.CancellationToken).ConfigureAwait(false); try {