Created
November 15, 2019 18:09
-
-
Save jdharmon/2e30f684ea2c66e510b653b4c1933a77 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void WaitForExitSignal() | |
{ | |
using (var signal = new ManualResetEventSlim()) | |
{ | |
// Handle SIGTERM | |
AssemblyLoadContext.Default.Unloading += _ => signal.Set(); | |
// Hadle SIGINT/Ctrl+C | |
Console.CancelKeyPress += (s, a) => | |
{ | |
a.Cancel = true; | |
signal.Set(); | |
}; | |
//Block until signaled | |
signal.Wait(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment