mirror of
https://github.com/SlothDpal/Relaunch-Process.git
synced 2026-02-22 17:27:38 +03:00
Minor fix
This commit is contained in:
35
Form1.cs
35
Form1.cs
@@ -268,37 +268,58 @@ namespace Process_Auto_Relaunch
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Обнаружение зависшего процесса по нагрузке
|
||||
/// </summary>
|
||||
/// <param name="cpuResponding"></param>
|
||||
/// <param name="cpuPrecent"></param>
|
||||
private void ProcessCheckResponding(bool cpuResponding, double cpuPrecent)
|
||||
{
|
||||
if (cpuResponding || cpuPrecent > 0.01)
|
||||
{
|
||||
if (waitResponceTimer != null)
|
||||
// Процесс отвечает
|
||||
// Если таймер ожидания запущен - отключаем.
|
||||
if (TimerResponceRuning())
|
||||
{
|
||||
StopTimerWaitingResponce();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Процесс не отвечает
|
||||
// Если таймер ожидания не запущен - запускаем
|
||||
if (!TimerResponceRuning())
|
||||
{
|
||||
StartTimerWaitingResponce();
|
||||
StartTimerWaitingResponce(5000, ProcessNotResponding);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Проверяет запущен ли таймер ожидания процесса
|
||||
/// </summary>
|
||||
/// <returns>True, если запущен</returns>
|
||||
private bool TimerResponceRuning()
|
||||
{
|
||||
return waitResponceTimer != null /*&& waitResponceTimer.Enabled*/;
|
||||
}
|
||||
|
||||
private void StartTimerWaitingResponce()
|
||||
/// <summary>
|
||||
/// Метод запуска таймера для ожидания процесса
|
||||
/// </summary>
|
||||
/// <param name="interval">Интервал таймера</param>
|
||||
/// <param name="timerElapsed">Метод, вызываемый после окончания таймера</param>
|
||||
private void StartTimerWaitingResponce(double interval, ElapsedEventHandler timerElapsed)
|
||||
{
|
||||
Debug.WriteLine("Запуск таймера ожидания процесса.");
|
||||
waitResponceTimer = new System.Timers.Timer(5000);
|
||||
waitResponceTimer.Elapsed += ProcessNotResponding;
|
||||
Debug.WriteLine($"Запуск таймера {interval} ms.");
|
||||
waitResponceTimer = new System.Timers.Timer(interval);
|
||||
waitResponceTimer.Elapsed += timerElapsed;
|
||||
waitResponceTimer.AutoReset = false;
|
||||
waitResponceTimer.Enabled = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Остановка таймера ожидания процесса
|
||||
/// </summary>
|
||||
private void StopTimerWaitingResponce()
|
||||
{
|
||||
Debug.WriteLine("Остановка таймера ожидания процесса.");
|
||||
@@ -333,7 +354,7 @@ namespace Process_Auto_Relaunch
|
||||
{
|
||||
if (ProcessByNameIsRuning(path))
|
||||
{
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
// Процесс не запущен
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
@@ -25,7 +26,6 @@
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Номер сборки
|
||||
// Редакция
|
||||
//
|
||||
[assembly: AssemblyVersion("1.4.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.4.0.0")]
|
||||
[assembly: AssemblyVersion("1.5.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.5.0.0")]
|
||||
|
||||
Reference in New Issue
Block a user