Created
May 7, 2018 11:01
-
-
Save lloydjatkinson/61bcb279f9733dffae8d9fa9298fe0eb to your computer and use it in GitHub Desktop.
This file contains 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
internal class Program | |
{ | |
private readonly static ManualResetEvent _manualResetEvent = new ManualResetEvent(false); | |
internal static void Main(string[] args) | |
{ | |
Console.WriteLine("Hello World!"); | |
Console.CancelKeyPress += HandleExit; | |
// Application logic here. | |
_manualResetEvent.WaitOne(); | |
} | |
internal static void HandleExit(object sender, ConsoleCancelEventArgs eventArguments) | |
{ | |
Console.WriteLine("Safely exiting."); | |
Thread.Sleep(3000); | |
eventArguments.Cancel = true; | |
_manualResetEvent.Set(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment