コード例 #1
0
        public static void ExecuteServiceAsConsole()
        {
            NativeMethods.AllocConsole();
            service   = new OpenVPNServiceRunner();
            _handler += new NativeMethods.HandlerRoutine(ConsoleCtrlCheck);

            // Allow console to properly take shutdown also on Ctrl+C or closing the Console window.
            NativeMethods.SetConsoleCtrlHandler(_handler, true);

            service.StartAsConsole();
            try
            {
                string input = string.Empty;
                Console.WriteLine("\r\nType \"exit\" and press Enter to stop.");
                while (input != null && input.ToLower() != "exit")
                {
                    input = Console.ReadLine();
                }
                service.Shutdown();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
コード例 #2
0
        public static void ExecuteServiceAsConsole()
        {
            NativeMethods.AllocConsole();
            service = new OpenVPNServiceRunner();
            _handler += new NativeMethods.HandlerRoutine(ConsoleCtrlCheck);

            // Allow console to properly take shutdown also on Ctrl+C or closing the Console window.
            NativeMethods.SetConsoleCtrlHandler(_handler, true);

            service.StartAsConsole();
            try
            {
                string input = string.Empty;
                Console.WriteLine("\r\nType \"exit\" and press Enter to stop.");
                while (input != null && input.ToLower() != "exit")
                    input = Console.ReadLine();
                service.Shutdown();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }