We have an OWIN application running on IIS and are currently using the AppProperties(IAppBuilder.Properties).OnAppDisposing cancellation token to detect when the application is being shutdown to gracefully shutdown some of the long running tasks that we start when the application starts.
The problem is that when the web.config is modified (even if just doing a "touch web.config") then the OnAppDisposing cancellation token is cancelled and our long running tasks shut themselves down. But the application pool is not actually recycled in these cases and so our long running tasks do not get restarted until the app pool is actually recycled.
How is one supposed to handle web.config changes in these instances? So that we can still detect OnAppDisposing and shutdown gracefully while also not have to worry about long running tasks shutting down and not getting started again?
Update: I've found that the OWIN app will get initialized again when the first http request comes in. But if there were Hangfire or other Background tasks that you expected to be running they won't be started again until that web request comes in. Even if you have application initialization setup, the appinit url is not hit after the app domain restart.