Console.ReadLine(); Console.ReadKey(); //无法在Linux运行
private static readonly AutoResetEvent _closingEvent = new AutoResetEvent(false); static void Main(string[] args) { //业务逻辑
// 监听CTRL+C Console.CancelKeyPress += ((s, a) => { Console.WriteLine("程序已退出!"); _closingEvent.Set(); }); _closingEvent.WaitOne(); }