private static void SignalHelper_OnSingalHandled(object sender, SingalEventArgs e) { System.Console.WriteLine(e.SigNum); switch (e.SigNum) { case Signum.SIGKILL: Console.WriteLine("killing me"); WaitPress(); break; case Signum.SIGTERM: Console.WriteLine("term me"); WaitPress(); break; case Signum.SIGQUIT: Console.WriteLine("termnal quit"); WaitPress(); break; case Signum.SIGHUP: Console.WriteLine("hungup me."); WaitPress(() => { Environment.Exit((int)e.SigNum); }); break; default: Console.WriteLine("default,do nothing"); break; } }
protected static void OnOnSingalHandled(SingalEventArgs e) { Task.Run(() => { try { OnSingalHandled?.Invoke(null, e); } catch (Exception ex) { //ignore } }); }