コード例 #1
0
        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;
            }
        }
コード例 #2
0
 protected static void OnOnSingalHandled(SingalEventArgs e)
 {
     Task.Run(() =>
     {
         try
         {
             OnSingalHandled?.Invoke(null, e);
         }
         catch (Exception ex)
         {
             //ignore
         }
     });
 }