Exemplo n.º 1
0
        /// <summary>
        /// Adds an action that will be executed when the Application exists.
        /// </summary>
        /// <param name="action"></param>
        public static void AddApplicationExitHandler(Action action)
        {
            EventHandler eventHandler = (EventHandler)((sender, evt) => action());

            AppUtil.processHooks.Add(eventHandler);
            AppDomain.CurrentDomain.ProcessExit += eventHandler;
            AppUtil.ConsoleCtrlHandler consoleCtrlHandler = (AppUtil.ConsoleCtrlHandler)(type =>
            {
                action();
                return(false);
            });
            AppUtil.ctrlHandlers.Add(consoleCtrlHandler);
            AppUtil.SetConsoleCtrlHandler(consoleCtrlHandler, true);
        }
Exemplo n.º 2
0
 public static extern bool SetConsoleCtrlHandler(AppUtil.ConsoleCtrlHandler consoleCtrlHandler, bool Add);