Created
June 9, 2020 03:59
-
-
Save milovidov983/ee8f9a906577b500b372003225f623ef to your computer and use it in GitHub Desktop.
background service
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
public static void Main(string[] args) { | |
var exitEvent = new System.Threading.ManualResetEvent(false); | |
Console.CancelKeyPress += (s, e) => { | |
e.Cancel = true; | |
exitEvent.Set(); | |
}; | |
//start your app | |
exitEvent.WaitOne(); | |
//stop your app | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment