Skip to content

Commit 2ea3a6e

Browse files
committed
Fix AsyncConsumerWorkService
1 parent 4577442 commit 2ea3a6e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

projects/client/RabbitMQ.Client/src/client/impl/AsyncConsumerWorkService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class WorkPool
4545
readonly ModelBase _model;
4646
CancellationTokenRegistration _tokenRegistration;
4747
volatile TaskCompletionSource<bool> _syncSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
48-
private Task _task;
48+
private Task _worker;
4949

5050
public WorkPool(ModelBase model)
5151
{
@@ -57,7 +57,7 @@ public WorkPool(ModelBase model)
5757

5858
public void Start()
5959
{
60-
_task = Task.Run(Loop, CancellationToken.None);
60+
_worker = Task.Run(Loop, CancellationToken.None);
6161
}
6262

6363
public void Enqueue(Work work)
@@ -80,7 +80,7 @@ async Task Loop()
8080
// Swallowing the task cancellation in case we are stopping work.
8181
}
8282

83-
if (!_tokenSource.IsCancellationRequested && _workQueue.TryDequeue(out Work work))
83+
while (_tokenSource.IsCancellationRequested == false && _workQueue.TryDequeue(out Work work))
8484
{
8585
await work.Execute(_model).ConfigureAwait(false);
8686
}

0 commit comments

Comments
 (0)