Example #1
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                try
                {
                    await _queueReader.HasMessage();
                }
                catch (OperationCanceledException)
                {
                    // swallow as likely shutting down
                }
                catch (Exception)
                {
                    // unhandled in the main code so kill the app

                    _hostApplicationLifetime.StopApplication();
                }
            }
        }