diff --git a/Form1.cs b/Form1.cs index 5337d55..7f3b659 100644 --- a/Form1.cs +++ b/Form1.cs @@ -327,6 +327,31 @@ namespace Process_Auto_Relaunch Status($"Процесс {ProcessName} запущен.", NotifyLevel.logAlways); } + /// + /// Метод принудительного завершения процесса + /// + /// + private void ProcessKill(Process process) + { + if (process == null || process.HasExited) + { + return; + } + + try + { + Status($"Попытка завершения процесса {process.ProcessName}", NotifyLevel.logHistory | NotifyLevel.logDiscord); + process.Kill(); + } + catch (Exception ex) + { + Status(ex.Message, NotifyLevel.logHistory | NotifyLevel.logDiscord); + return; + } + + Status($"Процесс был успешно завершён.", NotifyLevel.logHistory | NotifyLevel.logDiscord); + } + private void BackgroundWorkerDoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker;