Example #1
0
        public static void Main(string[] args)
        {
            ConsoleApp         app     = new ConsoleApp();
            CtrlHandlerRoutine handler = new CtrlHandlerRoutine(app.CtrlHandler);

            //Install a console ctrl handler so that we may unload the exceution domain
            //If the user wants to cancel by pressing Ctrl+C
            SetConsoleCtrlHandler(handler);
            app.Run(args);

            GC.KeepAlive(handler);
        }
Example #2
0
        static void AttachCtrlHandler()
        {
            if (CancelKeyPress == null)
            {
                CancelKeyPress = new CtrlHandlerRoutine(CtrlHandlerFunction);
            }

            if (!WinAPI.SetConsoleCtrlHandler(CancelKeyPress, true))
            {
                throw new ConsoleExException("ConsoleEx: Unable to set Ctrl handler.");
            }
        }
Example #3
0
        public static void RunMe(string[] filenames, string outputFileName, string nrfFilename, string[] filesToEmbed)
        {
            Slyce.Common.Utility.CheckForNulls(new object[] { filenames, outputFileName, nrfFilename, filesToEmbed }, new string[] { "filenames", "outputFileName", "nrfFilename", "filesToEmbed" });
            ConsoleApp         app     = new ConsoleApp();
            CtrlHandlerRoutine handler = new CtrlHandlerRoutine(app.CtrlHandler);

            //Install a console ctrl handler so that we may unload the exceution domain
            //If the user wants to cancel by pressing Ctrl+C
            SetConsoleCtrlHandler(handler);
            string[] args  = new string[filenames.Length + 2];
            int      index = 0;

            for (int i = 0; i < filenames.Length; i++)
            {
                args[i] = filenames[i];
                index++;
            }
            args[index]     = "outputFileName=" + outputFileName;
            args[index + 1] = "nrfFileName=" + nrfFilename;
            app.Run(args, filesToEmbed);
            GC.KeepAlive(handler);
        }
Example #4
0
        public static void RunMe(string[] filenames, string outputFileName, string nrfFilename, string[] filesToEmbed)
        {
            Slyce.Common.Utility.CheckForNulls(new object[] { filenames, outputFileName, nrfFilename, filesToEmbed }, new string[] { "filenames", "outputFileName", "nrfFilename", "filesToEmbed" });
            ConsoleApp app = new ConsoleApp();
            CtrlHandlerRoutine handler = new CtrlHandlerRoutine(app.CtrlHandler);

            //Install a console ctrl handler so that we may unload the exceution domain
            //If the user wants to cancel by pressing Ctrl+C
            SetConsoleCtrlHandler(handler);
            string[] args	= new string[filenames.Length + 2];
            int index		= 0;

            for (int i = 0; i < filenames.Length; i++)
            {
                args[i] = filenames[i];
                index++;
            }
            args[index]		= "outputFileName="+ outputFileName;
            args[index + 1] = "nrfFileName="+ nrfFilename;
            app.Run(args, filesToEmbed);
            GC.KeepAlive(handler);
        }
 private static extern bool SetConsoleCtrlHandler(CtrlHandlerRoutine handler, bool add);
Example #6
0
 static public extern bool SetConsoleCtrlHandler(CtrlHandlerRoutine HandlerRoutine, bool Add);
Example #7
0
 extern static bool SetConsoleCtrlHandler(CtrlHandlerRoutine handler);
Example #8
0
 /// <summary>
 /// 设置控制信号的处理方法。
 /// </summary>
 /// <param name="routine">处理方法。方法包含一个参数,表示控制信号的类型。</param>
 /// <returns></returns>
 public static bool AddCtrlHandler(CtrlHandlerRoutine routine)
 {
     return(SetConsoleCtrlHandler(routine, true));
 }
Example #9
0
 /// <summary>
 /// 移除控制信号的处理方法。
 /// </summary>
 /// <param name="routine">处理方法。方法包含一个参数,表示控制信号的类型。</param>
 /// <returns></returns>
 public static bool RemoveCtrlHandler(CtrlHandlerRoutine routine)
 {
     return(SetConsoleCtrlHandler(routine, false));
 }
Example #10
0
 static extern bool SetConsoleCtrlHandler(CtrlHandlerRoutine handler);