Description
The example for "Asynchronous timed background task" calls DoWork() which blocks before the ExecuteAsync method becomes asynchronous, which goes against the own advice on this page:
No further services are started until ExecuteAsync becomes asynchronous, such as by calling await. Avoid performing long, blocking initialization work in ExecuteAsync. The host blocks in StopAsync(CancellationToken) waiting for ExecuteAsync to complete.
Page URL
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-9.0&tabs=visual-studio
Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/fundamentals/host/hosted-services.md
Document ID
b2dece1f-15b8-03af-6d52-7cc070432b4b
Article author
@tdykstra
Metadata
- ID: c3460b0d-9c60-3a06-ac63-18cf990e53c3
- PlatformId: 397125bc-12c3-8f36-bb0b-efb01a1e9f43
- Service: aspnet-core
- Sub-service: fundamentals
Related Issues