问题
I have a restful micro service (web api) in .net 4.6.2 and I want to call a fire and forget function each time after certain endpoints are called to do some database cleanup work. I don' want to use Task.Run and I want to have a much reliable dedicated process to do this job.
I found lot's of articles and discussions about how to use IhostedService in .net core for long running background tasks.
https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/multi-container-microservice-net-applications/background-tasks-with-ihostedservice
https://thinkrethink.net/2018/02/21/asp-net-core-background-processing/
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-2.1
However I didn't find much information about the equivalent in .net framework. Is that IRegisteredObject? Can somebody please help me or direct me to the right resources.
Notes: We host the API as a windows service and don't use IIS
This is the first time I am asking a question here, therefore apologies if the question is not claer enough.
来源:https://stackoverflow.com/questions/51390284/equivalent-of-ihostedservice-in-asp-net-framework-for-background-tasks