/// <summary> /// The event called when the timer fires. /// </summary> private async Task EventsProcessorAsync() { // create all the processor tasks var tasks = new List <Task <long> >(); foreach (var processor in _processors) { tasks.Add(processor.WorkAsync(_token)); } try { // wait for everything await Wait.WhenAll(tasks, _logger, _token).ConfigureAwait(false); } catch (OperationCanceledException) { _logger.Warning("Received cancellation request - Processor timer."); throw; } catch (Exception e) { _logger.Exception(e); } // restart the timer if it has not been disposed... if (_timer != null) { await _timer.StartAsync().ConfigureAwait(false); } }