mirror of
https://github.com/SlothDpal/Relaunch-Process.git
synced 2026-02-22 17:27:38 +03:00
Added void Process Kill
This commit is contained in:
25
Form1.cs
25
Form1.cs
@@ -327,6 +327,31 @@ namespace Process_Auto_Relaunch
|
||||
Status($"Процесс {ProcessName} запущен.", NotifyLevel.logAlways);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Метод принудительного завершения процесса
|
||||
/// </summary>
|
||||
/// <param name="process"></param>
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user