private void PumpMessages()
{
while (!IsStopping)
{
pauseEvent.Wait();
IDelivery delivery;
try
{
delivery = deliveries.Take(cancellationTokenSource.Token);
}
catch (OperationCanceledException)
{
continue;
}
catch (InvalidOperationException)
{
break;
}
Deliver(delivery);
}
Status = WorkerStatus.Stopped;
}
}