File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
projects/RabbitMQ.Client/client/impl Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -128,7 +128,7 @@ private async Task LoopWithConcurrency(CancellationToken cancellationToken)
128
128
{
129
129
while ( await _channel . Reader . WaitToReadAsync ( cancellationToken ) . ConfigureAwait ( false ) )
130
130
{
131
- while ( _channel . Reader . TryRead ( out Work work ) && ! cancellationToken . IsCancellationRequested )
131
+ while ( _channel . Reader . TryRead ( out Work work ) )
132
132
{
133
133
// Do a quick synchronous check before we resort to async/await with the state-machine overhead.
134
134
if ( ! _limiter . Wait ( 0 ) )
@@ -144,6 +144,10 @@ private async Task LoopWithConcurrency(CancellationToken cancellationToken)
144
144
{
145
145
// ignored
146
146
}
147
+ finally
148
+ {
149
+ _limiter ? . Dispose ( ) ;
150
+ }
147
151
}
148
152
149
153
private static async Task HandleConcurrent ( Work work , IModel model , SemaphoreSlim limiter )
@@ -186,7 +190,6 @@ public Task Stop()
186
190
{
187
191
_channel . Writer . Complete ( ) ;
188
192
_tokenSource ? . Cancel ( ) ;
189
- _limiter ? . Dispose ( ) ;
190
193
return _worker ;
191
194
}
192
195
}
You can’t perform that action at this time.
0 commit comments