This post was originally published in Portuguese on my blog: Processando em segundo plano no .NET 8 com BackgroundService e Channel .
We've all been there: the endpoint receives a request, does something slow (generates a report, sends an email, calls a slow service) and the client sits waiting until it times out. The classic way out is to respond right away and do the work in the background. You can jump straight to a broker like RabbitMQ, but that's often overkill. In .NET 8 you already have what you need at home: BackgroundService and Channel<T> .
The idea
The API doesn't process anything. It registers the job, puts it in a queue and returns 202 Accepted with a Location header. On the other side, a BackgroundService loops reading from the queue and processing one job at a time.…