Last active
November 1, 2016 14:22
-
-
Save ctigeek/74d9f1c049ebec4f04ba0dad64e83f8d to your computer and use it in GitHub Desktop.
Run stuff and wait in program.cs
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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
ManualResetEventSlim manualResetEvent = null; | |
Console.CancelKeyPress += (sender, eventArgs) => | |
{ | |
Console.WriteLine("cancel!"); | |
manualResetEvent?.Set(); | |
}; | |
using (manualResetEvent = new ManualResetEventSlim(false)) | |
{ | |
//Start other code here.... | |
Console.WriteLine("Running...."); | |
manualResetEvent.Wait(); | |
} | |
Console.WriteLine("Exiting"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment