Background Services in ASP.NET Core and .NET
summary
Demonstrates turning a console app into a long‑running host using Microsoft.Extensions.Hosting, registers hosted work via BackgroundService, and shows the worker service template, container deployment, and new .NET 8 options to start/stop services concurrently. Builds a channel-based producer/consumer demo and a two‑service pipeline using S3 + SQS (localstack) that successfully moves upload processing off the request path. Covers gotchas: blocking start methods, fire‑and‑forget risks, synchronous work-before-first-await and Task.Yield as a workaround, plus the niche IHostedLifecycleService hooks.
AI-written summary · about
chapters (16)
- 0:00Introduction
- 1:54ASP.NET Core Host
- 8:08Console app to service
- 11:18Host internals lifecycle
- 22:54Basic background service
- 33:34Worker Service template
- 35:59Host lifecycle recap
- 40:09Offload work from requests
- 42:11Queue processing with services
- 47:27Out-of-process queue processing
- 51:39Real-world queue demo
- 52:02Exception handling in services
- 54:53Graceful shutdown draining
- 55:53Common pitfalls gotchas
- 56:36Key takeaways best practices
- 59:01Q&A
related talks
59mThe Background on Background Tasks in .NET Core
50mA Deep Dive on Running Background Tasks in .NET Core
01h 06mThe Background on Background Tasks in .NET 6
01h 05mAPIs and Microservices in ASP.NET Core Today and Tomorrow
01h 13mOwn the future, NSB-style
49mTaking your .NET Core container solution from laptop to production
58mMicroservices at Scale - ASP.NET Core, Service Fabric, and Azure in production
47mASP. NET Basics For Experts
