How to correctly and safely dispose of singletons instances registered in the container when an ASP.NET Core app shuts down
问题 I am looking for guidance on how to correctly and safely dispose of registered singleton instances when my ASP.NET Core 2.0 app is shutting down. According to the following document, if I register a singleton instance (via IServiceCollection) the container will never attempt to create an instance (nor will it dispose of the instance), thus I am left to dispose of these instances myself when the app shuts down. https://docs.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection?view