Ejemplo n.º 1
0
 // Console control event handler raises the ConsoleControlEvent.
 // This method is called by the console API when a control event occurs.
 private static bool ControlHandler(ConsoleControlEventType ctrlType)
 {
     switch (ctrlType)
     {
     case ConsoleControlEventType.CtrlC:
     case ConsoleControlEventType.CtrlBreak:
     case ConsoleControlEventType.CtrlClose:
     case ConsoleControlEventType.CtrlLogoff:
     case ConsoleControlEventType.CtrlShutdown:
         if (ControlEvent != null)
         {
             ConsoleControlEventArgs e = new ConsoleControlEventArgs(ctrlType);
             ControlEvent(null, e);
             return(e.Cancel);
         }
         break;
     }
     return(false);
 }
Ejemplo n.º 2
0
 // Console control event handler raises the ConsoleControlEvent.
 // This method is called by the console API when a control event occurs.
 private static bool ControlHandler(ConsoleControlEventType ctrlType)
 {
     switch (ctrlType)
     {
         case ConsoleControlEventType.CtrlC:
         case ConsoleControlEventType.CtrlBreak:
         case ConsoleControlEventType.CtrlClose:
         case ConsoleControlEventType.CtrlLogoff:
         case ConsoleControlEventType.CtrlShutdown:
             if (ControlEvent != null)
             {
                 ConsoleControlEventArgs e = new ConsoleControlEventArgs(ctrlType);
                 ControlEvent(null, e);
                 return e.Cancel;
             }
             break;
     }
     return false;
 }