public static void End() { if (Message != null) { Message.End(); Message = null; if (channel != null) { ChannelServices.UnregisterChannel(channel); channel = null; } } if (ServerProcess != null) { if (!ServerProcess.HasExited) { ServerProcess.Kill(); } ServerProcess.Dispose(); ServerProcess = null; } }
/// <summary> /// Kill the server /// </summary> public static void KillServer() { if (ServerProcess != null && !ServerProcess.HasExited) { ServerProcess.Kill(); } }
public void CrashWithDialog(string caption, string text) { _crashWithDialog = true; int k = 0; while (!ServerStatus.Status && k < 40) { Thread.Sleep(50); k++; } if (!(this is ValveHltvServer) && ServerStatus.Map.Length > 0) { _logger.Warn(string.Format(Properties.Resources.log_ServerCrashedWithDialogOnMap.Replace("\\n", "\n"), Options.HostName, ServerStatus.Map, ConsoleText.Trim(), caption, text)); } else { _logger.Warn(string.Format(Properties.Resources.log_ServerCrashedWithDialog.Replace("\\n", "\n"), Options.HostName, ConsoleText.Trim(), caption, text)); } //while (_serverThread.ThreadState != System.Threading.ThreadState.WaitSleepJoin && k < 40) //{ // Thread.Sleep(50); // k++; //} try { ServerProcess.Kill(); } catch (Exception e) { _logger.DebugException(Properties.Resources.log_ProcessAlreadyKilled, e); } Thread.Sleep(100); }
public async Task Close() { try { ServerProcess.Kill(); } catch { } }
public override void Stop() { if (ServerProcess != null) { ServerProcess.Kill(); ServerProcess = null; } }
public virtual void Kill() { if (_serverThread != null) { _serverThread.Abort(); } try { ServerProcess.Kill(); } catch { } }
public void Stop() { try { Logger.Debug("Closing Server"); ServerProcess.Kill(); Logger.Debug("Waiting for exit of Server"); ServerProcess.WaitForExit(); Logger.Debug("Server ended"); } catch (Exception ex) { Logger.Debug("Got exception during server stop.", ex); } }
private void Exit_Click(object sender, RoutedEventArgs e) { if (ServerIsRunning == true) { ServerProcess.OutputDataReceived -= new DataReceivedEventHandler(ServerOutput_OutputDataRecieved); ServerProcess.Exited -= new EventHandler(ServerClose_Exited); ServerProcess.Kill(); } ModsPluginsWatcher.Changed -= ModsPlugins_OnChanged; ModsPluginsWatcher.Created -= ModsPlugins_OnChanged; ModsPluginsWatcher.Deleted -= ModsPlugins_OnChanged; ModsPluginsWatcher.Renamed -= ModsPlugins_OnChanged; Application.Current.Shutdown(); }
public bool Stop(bool forceful = false) { if (!ServerRunning) { return(true); } WriteInput("stop"); bool exited = ServerProcess.WaitForExit(Convert.ToInt32(TimeSpan.FromSeconds(30).TotalMilliseconds)); if (exited) { SetStatus(ServerStatus.Stopped); } else if (forceful) { ServerProcess.Kill(); SetStatus(ServerStatus.Stopped); return(true); } return(exited); }
/// <summary> /// Stop the server process, by sending a stop signal to the process /// </summary> public static void StopServerProcess() { RaiseServerStopping(); ServerProcess.Kill(); }
public virtual void Stop() { if (_serverThread != null) { if (_serverThread.ThreadState == System.Threading.ThreadState.Running || _serverThread.ThreadState == System.Threading.ThreadState.WaitSleepJoin) { _serverThread.Abort(); if (ServerProcess != null) { try { if (this is ValveHltvServer) { _logger.Info(string.Format(Properties.Resources.log_KillProcessShutdown, Options.HostName)); try { ServerProcess.Kill(); } catch (Exception e) { _logger.DebugException(Properties.Resources.log_ProcessAlreadyKilled, e); } } else { _logger.Info(string.Format(Properties.Resources.log_TryingNormalShutdown, Options.HostName)); if (SendMessageUtil.SendTextMessage("quit", ServerProcess)) { ServerProcess.WaitForExit(3000); if (!ServerProcess.HasExited) { _logger.Warn(string.Format(Properties.Resources.log_NormalShutdownFailed, Options.HostName)); _logger.Info(string.Format(Properties.Resources.log_KillProcessShutdown, Options.HostName)); try { ServerProcess.Kill(); } catch (Exception e) { _logger.DebugException(Properties.Resources.log_ProcessAlreadyKilled, e); } } } else { try { ServerProcess.Kill(); } catch (Exception e) { _logger.DebugException(Properties.Resources.log_ProcessAlreadyKilled, e); } } } } catch { try { ServerProcess.Kill(); } catch (Exception e) { _logger.DebugException(Properties.Resources.log_ProcessAlreadyKilled, e); } } } _logger.Info(string.Format(Properties.Resources.log_SuccessfulStopped, Options.HostName)); OnServerStoped(this, new EventArgs()); } else { _logger.Info(string.Format(Properties.Resources.log_ServerAlreadyStopped, Options.HostName)); } } else { _logger.Info(string.Format(Properties.Resources.log_ServerAlreadyStopped, Options.HostName)); } }