Skip to content

Conversation

@davidfowl
Copy link
Member

  • The generic web hosted service is added before any user code runs, as a result it's impossible to write a hosted services that run before server startup. This behavior differs from what happens when you use the Startup class today. We call ConfigureServices then we add the IHostedService implementation that starts the server. This change mimics that behavior by adding the initial set of hosted services after your code runs.
  • Added a test

Fixes #35454

- The generic web hosted service is added before any user code runs, as a result its impossible to write a hosted services that run before server startup. This behavior differs from what happens when you use the Startup class today. We call ConfigureServices then we add the IHostedService implementation that starts the server. This change mimics that behavior by adding the initial set of hosted services after your code runs.
- Added a test
@davidfowl davidfowl merged commit 45523fd into main Sep 3, 2021
@davidfowl davidfowl deleted the davidfowl/run-user-hosted-services-first branch September 3, 2021 04:52
@ghost ghost added this to the 7.0-preview1 milestone Sep 3, 2021
@davidfowl
Copy link
Member Author

/backport to release/6.0

@github-actions
Copy link
Contributor

github-actions bot commented Sep 3, 2021

@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Minimal API does not start HostedService before accepting requests

4 participants