diff --git a/src/Proto.Actor/Mailbox/BatchingMailbox.cs b/src/Proto.Actor/Mailbox/BatchingMailbox.cs index ba23070d27..8367d650e2 100644 --- a/src/Proto.Actor/Mailbox/BatchingMailbox.cs +++ b/src/Proto.Actor/Mailbox/BatchingMailbox.cs @@ -79,8 +79,8 @@ private async Task RunAsync() { batch.Clear(); - while ((msg = _userMessages.Pop()) is not null || - batch.Count >= _batchSize) + while (batch.Count < _batchSize && + (msg = _userMessages.Pop()) is not null) { batch.Add(msg!); }