Exit() protected method

protected Exit ( int aCode ) : void
aCode int
return void
Exemplo n.º 1
0
 protected override void OnStop()
 {
     lock (_lock)
     {
         if (!IsRunning)
         {
             return;
         }
         IsRunning = false;
     }
     Debug.WriteLine($"Service [{ServiceName}] stopped");
     try
     {
         _shouldRestart = false;
         _process.Exit();
     }
     catch (Exception exception)
     {
         Debug.WriteLine(exception);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Stops the current service and kills the hosted application.
        /// </summary>
        protected override void OnStop()
        {
            STrace.Debug(GetType().FullName, "Descargando Aplicacion: {0}", ServiceName);

            _application.Unload();

            STrace.Debug(GetType().FullName, "Terminando servicio windows: {0}", ServiceName);

            Thread.Sleep(TimeSpan.FromSeconds(5));

            Process.Exit(Process.ExitCodes.ServiceStop, "Detenido por el usuario.");
        }
Exemplo n.º 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            //StartService(svcInterQ, true);
            //StartService(svcOVPN, true);
            Devices.i().LockUpdateDevices();
            var aaa = new DBUpdateForm();

            if (aaa.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                MessageBox.Show(
                    "La actualizacion se completo con exito, la aplicacion se cerrara.",
                    "Datos Actualizados", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Process.Exit();
                return;
            }
            Devices.i().ReleaseUpdateDevices();
            MessageBox.Show(
                "La actualizacion fallo, asegurese que su conexion a internet funciona correctamente y que la red privada se encuentra operativa. Vuelva a intentarlo en algunos minutos, si el problema persiste, comuniquese con el administrador del sisitema. Gracias.",
                "Imposible actualizar los datos", MessageBoxButtons.OK, MessageBoxIcon.Stop);
        }
Exemplo n.º 4
0
        public static ContextMenu GetInstance()
        {
            if (_menu == null)
            {
                _items = new MenuItem[ITEM_COUNT];

                _items[0] = new MenuItem("启用系统代理", new EventHandler(IsProxyOn_OnClick))
                {
                    Checked = _config.IsProxyOn
                };
                MenuItem[] _proxyModeItems = new MenuItem[2];
                _proxyModeItems[0] = new MenuItem("PAC模式", new EventHandler(PacProxyMode_OnClick))
                {
                    Checked = _config.ProxyMode == ProxyMode.Pac
                };
                _proxyModeItems[1] = new MenuItem("全局模式", new EventHandler(SysProxyMode_OnClick))
                {
                    Checked = _config.ProxyMode == ProxyMode.Sys
                };
                _items[1] = new MenuItem("系统代理模式", _proxyModeItems)
                {
                    Enabled = _config.IsProxyOn
                };
                _items[2] = new MenuItem("-");
                _items[3] = new MenuItem("编辑config.json", new EventHandler(EditConfigFile_OnClick));
                _items[4] = new MenuItem("编辑PAC文件", new EventHandler(EditPacFile_OnClick));
                _items[5] = new MenuItem("-");
                _items[6] = new MenuItem("重启V2Ray进程", new EventHandler(RestartProcess_OnClick));
                _items[7] = new MenuItem("开机启动", new EventHandler(AutoStart_OnClick))
                {
                    Checked = _config.IsAutoStart
                };
                _items[8] = new MenuItem("-");
                _items[9] = new MenuItem("退出", (sender, e) => Process.Exit());

                _menu = new ContextMenu(_items);
            }
            return(_menu);
        }
Exemplo n.º 5
0
 public void Do()
 {
     Process.Exit();
 }
Exemplo n.º 6
0
 private void QueueDocument_FormClosing(object sender, FormClosingEventArgs e)
 {
     Process.Exit();
 }
Exemplo n.º 7
0
 private void SpineStandalone_FormClosing(object sender, FormClosingEventArgs e)
 {
     InterQServer.Stop();
     Process.Exit(Process.ExitCodes.Voluntary, "el usuario cerro la ventana Standalone.");
 }
Exemplo n.º 8
0
        unsafe static void Main(string[] args)
        {
            Console.WriteLine("\nProject Sharpen");
            Console.WriteLine("(c) 2016-2017 SharpNative\n");

            string currentDir = Directory.GetCurrentDirectory();

            while (true)
            {
                // Prompt
                Console.Write(currentDir);
                Console.Write("> ");

                // Read line
                string read = Console.ReadLine();
                if (read.Length == 0)
                {
                    Heap.Free(read);
                    continue;
                }

                // Split command line
                int argc = String.Count(read, ' ') + 1;

                // Copy for NULL ending
                string[] argv  = new string[argc + 1];
                string[] split = read.Split(' ');
                for (int i = 0; i < argc; i++)
                {
                    argv[i] = split[i];
                }

                string command = argv[0];

                Heap.Free(split);

                // Remove the empty arguments
                for (int i = 0; i < argc; i++)
                {
                    if (argv[i].Length == 0)
                    {
                        Heap.Free(argv[i]);
                        argv[i] = null;
                        argc--;
                    }
                }

                // Process commands
                if (command.Equals("cd"))
                {
                    if (argc != 2)
                    {
                        Console.WriteLine("Invalid usage of cd: cd [dirname]");
                    }
                    else
                    {
                        if (!Directory.SetCurrentDirectory(argv[1]))
                        {
                            Console.WriteLine("cd: Couldn't change the directory");
                        }
                        else
                        {
                            string old = currentDir;
                            currentDir = Directory.GetCurrentDirectory();
                            Heap.Free(old);
                        }
                    }
                }
                else if (command.Equals("dir"))
                {
                    Directory dir = Directory.Open(currentDir);

                    while (true)
                    {
                        Directory.DirEntry entry = dir.Readdir();
                        if (entry.Name[0] == '\0')
                        {
                            break;
                        }

                        string str = Util.CharPtrToString(entry.Name);
                        Console.WriteLine(str);
                    }

                    dir.Close();
                    Heap.Free(dir);
                }
                else if (command.Equals("print"))
                {
                    Print(argv, argc);
                }
                else if (command.Equals("echo"))
                {
                    Print(argv, argc);
                }
                else if (command.Equals("exit"))
                {
                    Process.Exit(0);
                }
                else if (command.Equals("background"))
                {
                    // Try to start a process without waiting until exit
                    string[] offsetArgv = (string[])Array.CreateSubArray((object[])argv, 1, argc - 1);

                    int ret = tryStartProcess(offsetArgv[0], offsetArgv);
                    if (ret > 0)
                    {
                        Console.Write("Process started in background with PID ");
                        Console.Write(ret);
                    }
                    Console.Write('\n');
                    Heap.Free(offsetArgv);
                }
                else
                {
                    // Try to start a process and wait until exit to return to prompt
                    int ret = tryStartProcess(command, argv);
                    if (ret > 0)
                    {
                        Process.WaitForExit(ret);
                    }
                    else
                    {
                        Console.Write(command);
                        Console.WriteLine(": Bad command or filename");
                    }
                }

                // Note: command is in the first entry of argv
                for (int i = 0; i < argc; i++)
                {
                    if (argv[i] != null)
                    {
                        Heap.Free(argv[i]);
                    }
                }
                Heap.Free(read);
                Heap.Free(argv);
            }
        }
Exemplo n.º 9
0
 private void button1_Click(object sender, EventArgs e)
 {
     Process.Exit(Process.ExitCodes.Voluntary, "El usuario presiono el boton 'Terminar'");
 }
Exemplo n.º 10
0
 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     Process.Exit(Process.ExitCodes.Voluntary, "El usuario cerror el formulario.");
 }