BackgroundService silently dies if an exception escapes. Rule Always wrap execution loops. while (!stoppingToken.IsCancellationRequested) { try { await DoWork(); } catch (Exception ex) { Log(ex); } } Why Unhandled exceptions kill the worker.
Daily micro-tips for C#, SQL, performance, and scalable backend engineering.
BackgroundService silently dies if an exception escapes. Rule Always wrap execution loops. while (!stoppingToken.IsCancellationRequested) { try { await DoWork(); } catch (Exception ex) { Log(ex); } } Why Unhandled exceptions kill the worker.