In some situations my web application requires to immediately quit during start-up. When doing so via System.Environment.Exit(int exitCode)
, the dotnet process does not exit.
Minimal set-up to reproduce:
public static void Main(string[] args) { var host = new WebHostBuilder() .UseKestrel() .UseStartup<Startup>() .Build(); host.Run(); }
public override void Configure(IApplicationBuilder app) { System.Environment.Exit(1); }
It seems that in this scenario Set()
will no longer be called on the instance of ManualResetEventSlim passed to AttachCtrlcSigtermShutdown(..)
resulting in the Shutdown()
method to block indefinitely.
One possible solution could be applying the WebHostOptions.ShutdownTimeout
when waiting for the manual reset event.
System Info:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4