Minor fix

This commit is contained in:
Vladimir
2024-07-28 14:22:32 +04:00
parent f8377fc5cd
commit 41d8a0a3e2
3 changed files with 33 additions and 12 deletions

View File

@@ -74,7 +74,7 @@ namespace Process_Auto_Relaunch
{
radioButtonEnableWathing.Checked = Settings.Default.enableWatching;
}
}
/// <summary>
@@ -211,7 +211,7 @@ namespace Process_Auto_Relaunch
// webhookDiscordToolStripMenuItem.Enabled = !watching;
// отключаем меню настроек
settingsToolStripMenuItem.Enabled = !watching;
Settings.Default.enableWatching = watching;
}
@@ -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;
}
// Процесс не запущен

View File

@@ -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>

View File

@@ -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")]