.NET/C#
C# console application keep alive. 콘솔 꺼짐 방지
네코냥이
2016. 4. 8. 19:16
--------------------------------------------------------------------------------------------------------------
static ManualResetEvent _quitEvent = new ManualResetEvent(false);
static void Main() {
Console.CancelKeyPress += (sender, eArgs) => {
_quitEvent.Set();
eArgs.Cancel = true;
};
// kick off asynchronous stuff
_quitEvent.WaitOne();
// cleanup/shutdown and quit
}
--------------------------------------------------------------------------------------------------------------