-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Description
Description
What will happen if ExecuteAsync is a synchronous and is a really long running, like several hours?
StartAsync will hang for a long time and the rest of that application will wait for that quote background service to finish what it does.
How can we avoid this? Should we use Task.Run or Task.Factory.StartNew with a LongRunning parameter or add await Task.Delay(1) to the first line of ExecuteAsync or Thread + TaskCompletitionSource or something else? Searching for an answer to this question is harder than it might look.
So I think this article is a perfect place to show a solution to that problem, which is very common I believe.
Page URL
Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/fundamentals/host/hosted-services.md
Document ID
b2dece1f-15b8-03af-6d52-7cc070432b4b