@@ -77,8 +77,7 @@ static bool ShouldTriggerConnectionRecovery(ShutdownEventArgs args)
7777 * https://github.com/rabbitmq/rabbitmq-dotnet-client/issues/826
7878 * Happens when an AppDomain is unloaded
7979 */
80- if ( args . Exception is ThreadAbortException &&
81- args . ReplyCode == Constants . InternalError )
80+ if ( args is { Exception : ThreadAbortException , ReplyCode : Constants . InternalError } )
8281 {
8382 return false ;
8483 }
@@ -407,7 +406,7 @@ await _config.TopologyRecoveryExceptionHandler.QueueRecoveryExceptionHandlerAsyn
407406 }
408407 finally
409408 {
410- await _recordedEntitiesSemaphore . WaitAsync ( )
409+ await _recordedEntitiesSemaphore . WaitAsync ( cancellationToken )
411410 . ConfigureAwait ( false ) ;
412411 }
413412 }
@@ -494,7 +493,7 @@ await _recordedEntitiesSemaphore.WaitAsync(cancellationToken)
494493 }
495494
496495 internal async ValueTask RecoverConsumersAsync ( AutorecoveringChannel channelToRecover , IChannel channelToUse ,
497- bool recordedEntitiesSemaphoreHeld = false )
496+ bool recordedEntitiesSemaphoreHeld = false , CancellationToken cancellationToken = default )
498497 {
499498 if ( _disposed )
500499 {
@@ -520,7 +519,8 @@ internal async ValueTask RecoverConsumersAsync(AutorecoveringChannel channelToRe
520519 }
521520 finally
522521 {
523- _recordedEntitiesSemaphore . Wait ( ) ;
522+ await _recordedEntitiesSemaphore . WaitAsync ( cancellationToken )
523+ . ConfigureAwait ( false ) ;
524524 }
525525
526526 string oldTag = consumer . ConsumerTag ;
@@ -540,7 +540,7 @@ internal async ValueTask RecoverConsumersAsync(AutorecoveringChannel channelToRe
540540 }
541541 finally
542542 {
543- await _recordedEntitiesSemaphore . WaitAsync ( )
543+ await _recordedEntitiesSemaphore . WaitAsync ( cancellationToken )
544544 . ConfigureAwait ( false ) ;
545545 }
546546 }
@@ -558,7 +558,7 @@ await _config.TopologyRecoveryExceptionHandler.ConsumerRecoveryExceptionHandlerA
558558 }
559559 finally
560560 {
561- await _recordedEntitiesSemaphore . WaitAsync ( )
561+ await _recordedEntitiesSemaphore . WaitAsync ( cancellationToken )
562562 . ConfigureAwait ( false ) ;
563563 }
564564 }
0 commit comments