Example #1
0
        private void ctrlEvent(object sender, ConsoleCtrlEventArgs consoleEvent)
        {
            consoleEvent.CallDefaultHandler = false;
            if (IgnoreCtrlC && consoleEvent.ConsoleEvent == ConsoleEvent.CtrlC)
            {
                return;
            }


            if (_timer == null)
            {
                _timer = new System.Threading.Timer(abortFunc, null, (long)AbortDelay.TotalMilliseconds, Timeout.Infinite);
                try
                {
                    var ou = Output;
                    if (ou != null)
                    {
                        ou.WriteLine("^C");
                    }

                    var ab = Abort;
                    ab.Invoke(this, new EventArgs());

                    _canExit.WaitOne();
                    Thread.Sleep(500);
                }
                catch
                {
                }
            }
        }
Example #2
0
 private bool handler(ConsoleEvent consoleEvent)
 {
     if (ControlEvent != null)
     {
         var a = new ConsoleCtrlEventArgs(consoleEvent);
         a.CallDefaultHandler = true;
         ControlEvent(this, a);
         return(!a.CallDefaultHandler);
     }
     return(false);
 }
Example #3
0
        private void ctrlEvent(object sender, ConsoleCtrlEventArgs consoleEvent)
        {
            consoleEvent.CallDefaultHandler = false;
            if (IgnoreCtrlC && consoleEvent.ConsoleEvent == ConsoleEvent.CtrlC)
                return;

            if (_timer == null)
            {

                _timer = new System.Threading.Timer(abortFunc, null, (long)AbortDelay.TotalMilliseconds, Timeout.Infinite);
                try
                {
                    var ou = Output;
                    if (ou != null)
                        ou.WriteLine("^C");

                    var ab = Abort;
                    ab.Invoke(this, new EventArgs());

                    _canExit.WaitOne();
                    Thread.Sleep(500);
                }
                catch
                {
                }
            }
        }
Example #4
0
 private bool handler(ConsoleEvent consoleEvent)
 {
     if (ControlEvent != null)
     {
         var a = new ConsoleCtrlEventArgs(consoleEvent);
         a.CallDefaultHandler = true;
         ControlEvent(this, a);
         return !a.CallDefaultHandler;
     }
     return false;
 }