Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asynchronous timed background task example doesn't follow own guidelines for background service #34744

Open
antmeehan opened this issue Feb 17, 2025 · 2 comments · May be fixed by dotnet/AspNetCore.Docs.Samples#272
Labels
aspnet-core/svc fundamentals/subsvc Source - Docs.ms Docs Customer feedback via GitHub Issue

Comments

@antmeehan
Copy link

antmeehan commented Feb 17, 2025

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

@Rick-Anderson
Copy link
Contributor

Would you or @huan086 be interested in updating the sample code? We'll take care of the article.

@antmeehan
Copy link
Author

I've created dotnet/AspNetCore.Docs.Samples#272 with my suggested changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aspnet-core/svc fundamentals/subsvc Source - Docs.ms Docs Customer feedback via GitHub Issue
Projects
None yet
2 participants