Skip to content

Instantly share code, notes, and snippets.

@ctigeek
Last active November 1, 2016 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctigeek/74d9f1c049ebec4f04ba0dad64e83f8d to your computer and use it in GitHub Desktop.
Save ctigeek/74d9f1c049ebec4f04ba0dad64e83f8d to your computer and use it in GitHub Desktop.
Run stuff and wait in program.cs
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