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());
            }
        }
 public OpenVPNService(OpenVPNServiceRunner openVPNserviceRunner, string vpnPath, string config)
 {
     this.openVPNserviceRunner = openVPNserviceRunner;
     this.config            = config;
     this.vpnPath           = vpnPath;
     this.configID          = counter++;
     terminatorEventName    = "OpenVPNManager_OpenVPNClientsReset_" + configID.ToString();
     terminateOpenVPNclient = new EventWaitHandle(false, EventResetMode.ManualReset, terminatorEventName);
 }
 public OpenVPNService(OpenVPNServiceRunner openVPNserviceRunner, string vpnPath, string config)
 {
     this.openVPNserviceRunner = openVPNserviceRunner;
     this.config = config;
     this.vpnPath = vpnPath;
     this.configID = counter++;
     terminatorEventName = "OpenVPNManager_OpenVPNClientsReset_" + configID.ToString();
     terminateOpenVPNclient = new EventWaitHandle(false, EventResetMode.ManualReset, terminatorEventName);
 }
        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());
            }
        }