Fix comportamento lock threads
This commit is contained in:
Binary file not shown.
+1
-1
@@ -8,7 +8,7 @@
|
||||
<add key="appNameExt" value="IOB-WIN" />
|
||||
<add key="uiPeriod" value="100" />
|
||||
<add key="checkPeriod" value="1000" />
|
||||
<add key="forceCheckPeriod" value="15000" />
|
||||
<add key="forceCheckPeriodMult" value="15" />
|
||||
<add key="autoRestartTimeoutMin" value="15" />
|
||||
<add key="autoStartProc" value="true" />
|
||||
<add key="closeOnChildUpdate" value="true" />
|
||||
|
||||
+40
-55
@@ -25,16 +25,16 @@ namespace IOB_MAN
|
||||
private const int SW_SHOWMINIMIZED = 2;
|
||||
private const int SW_SHOWNORMAL = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto locker x evitare problemi timer
|
||||
/// </summary>
|
||||
private static object _locker = new object();
|
||||
|
||||
/// <summary>
|
||||
/// Context x sync thread
|
||||
/// </summary>
|
||||
private readonly SynchronizationContext synchronizationContext;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto semaforico di lock
|
||||
/// </summary>
|
||||
private SemaphoreSlim _sync = new SemaphoreSlim(1);
|
||||
|
||||
/// <summary>
|
||||
/// Binding source degli elementi gestiti..
|
||||
/// </summary>
|
||||
@@ -57,7 +57,7 @@ namespace IOB_MAN
|
||||
/// <summary>
|
||||
/// Counter del timer di base
|
||||
/// </summary>
|
||||
protected int checkPeriod = 1000;
|
||||
protected int checkPeriod = 2000;
|
||||
|
||||
/// <summary>
|
||||
/// semaforo check...
|
||||
@@ -67,7 +67,7 @@ namespace IOB_MAN
|
||||
/// <summary>
|
||||
/// Counter del timer di forceCheck (60 sec, era 5 sec)
|
||||
/// </summary>
|
||||
protected int forceCheckPeriod = 60000;
|
||||
protected int forceCheckPeriodMult = 30;
|
||||
|
||||
/// <summary>
|
||||
/// Indica ultimo stato del check di restart...
|
||||
@@ -84,6 +84,16 @@ namespace IOB_MAN
|
||||
/// </summary>
|
||||
protected int lastNumProcRunning = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Numero di Lock effettuati con successo
|
||||
/// </summary>
|
||||
protected int numLockFail = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Numero di lock falliti
|
||||
/// </summary>
|
||||
protected int numLockSuccess = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Totale processi avviati
|
||||
/// </summary>
|
||||
@@ -105,9 +115,9 @@ namespace IOB_MAN
|
||||
protected string TargetName = "";
|
||||
|
||||
/// <summary>
|
||||
/// Contatore autockeck nativo
|
||||
/// Dataora prossima scadenza riavvio automatico
|
||||
/// </summary>
|
||||
protected int tOutAutocheck = 100;
|
||||
protected DateTime tOutAutocheck = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// Counter del timer UI
|
||||
@@ -314,7 +324,7 @@ namespace IOB_MAN
|
||||
|
||||
private void btnMoreTOut_Click(object sender, EventArgs e)
|
||||
{
|
||||
tOutAutocheck += 60 * utils.CRI("autoRestartTimeoutMin") * (1000 / (utils.CRI("checkPeriod")));
|
||||
tOutAutocheck = tOutAutocheck.AddMinutes(utils.CRI("autoRestartTimeoutMin"));
|
||||
}
|
||||
|
||||
private void btnOpenAll_Click(object sender, EventArgs e)
|
||||
@@ -410,32 +420,23 @@ namespace IOB_MAN
|
||||
/// </summary>
|
||||
private async Task checkProcessStatusAsync()
|
||||
{
|
||||
var hasLock = false;
|
||||
try
|
||||
{
|
||||
Monitor.TryEnter(_locker, ref hasLock);
|
||||
if (!hasLock)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!checkRunning)
|
||||
{
|
||||
// reset variabili appoggio
|
||||
checkRunning = true;
|
||||
// eseguo task!
|
||||
await Task.Run(() => checkRunningchild()).ConfigureAwait(false);
|
||||
updateStatus();
|
||||
checkRunning = false;
|
||||
}
|
||||
}
|
||||
finally
|
||||
await _sync.WaitAsync();
|
||||
|
||||
if (!checkRunning)
|
||||
{
|
||||
// reset variabili appoggio
|
||||
checkRunning = true;
|
||||
// eseguo task!
|
||||
await Task.Run(() => checkRunningchild()).ConfigureAwait(false);
|
||||
updateStatus();
|
||||
checkRunning = false;
|
||||
if (hasLock)
|
||||
{
|
||||
Monitor.Exit(_locker);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
utils.lgInfo($"Error: checkRunning: {checkRunning}");
|
||||
}
|
||||
|
||||
_sync.Release();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -505,7 +506,7 @@ namespace IOB_MAN
|
||||
private void chkAutoRestart_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
// se tolgo autorestart --> imposto NUOVA scadenza x forzare check
|
||||
tOutAutocheck = 60 * utils.CRI("autoRestartTimeoutMin") * (1000 / (utils.CRI("checkPeriod")));
|
||||
tOutAutocheck = DateTime.Now.AddMinutes(utils.CRI("autoRestartTimeoutMin"));
|
||||
txtTOutAutoCheck.Visible = !chkAutoRestart.Checked;
|
||||
btnMoreTOut.Visible = !chkAutoRestart.Checked;
|
||||
// fa subito controllo riavvio...
|
||||
@@ -744,21 +745,6 @@ namespace IOB_MAN
|
||||
|
||||
private void forceCheckTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
#if false
|
||||
if (!checkRunning)
|
||||
{
|
||||
try
|
||||
{
|
||||
Task result = checkProcessStatusAsync();
|
||||
result.Wait();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Logging.Instance.Error($"forceCheckTimer_Tick {exc}");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!checkRunning)
|
||||
{
|
||||
try
|
||||
@@ -856,7 +842,7 @@ namespace IOB_MAN
|
||||
MainTimer.Start();
|
||||
UI_Timer.Interval = uiPeriod;
|
||||
UI_Timer.Start();
|
||||
forceCheckTimer.Interval = forceCheckPeriod;
|
||||
forceCheckTimer.Interval = checkPeriod * forceCheckPeriodMult;
|
||||
forceCheckTimer.Start();
|
||||
// avvio il task con apposita classe Steamware... da 00:30
|
||||
int fullRestartHour = memLayer.ML.CRI("fullRestartHour");
|
||||
@@ -934,7 +920,7 @@ namespace IOB_MAN
|
||||
waitForExitMsec = utils.CRI("waitForExitMsec");
|
||||
checkPeriod = utils.CRI("checkPeriod");
|
||||
uiPeriod = utils.CRI("uiPeriod");
|
||||
forceCheckPeriod = utils.CRI("forceCheckPeriod");
|
||||
forceCheckPeriodMult = utils.CRI("forceCheckPeriodMult");
|
||||
TargetExe = utils.CRS("targetExe");
|
||||
TargetName = utils.CRS("appNameExt");
|
||||
if (string.IsNullOrEmpty(TargetExe))
|
||||
@@ -1075,7 +1061,7 @@ namespace IOB_MAN
|
||||
else
|
||||
{
|
||||
// se autorestart scaduto e NON checked --> lo imposto
|
||||
if (tOutAutocheck < 0)
|
||||
if (tOutAutocheck < DateTime.Now)
|
||||
{
|
||||
// lo riattivo
|
||||
chkAutoRestart.Checked = true;
|
||||
@@ -1239,13 +1225,12 @@ namespace IOB_MAN
|
||||
// se NON checked aggiorno contatore...
|
||||
if (!chkAutoRestart.Checked)
|
||||
{
|
||||
tOutAutocheck--;
|
||||
txtTOutAutoCheck.Text = $"{(tOutAutocheck / (1000 / (utils.CRI("checkPeriod"))))}";
|
||||
txtTOutAutoCheck.Text = $"{tOutAutocheck.Subtract(DateTime.Now).TotalSeconds:N0}";
|
||||
}
|
||||
// se è variato...
|
||||
if (hlRestart != lastHlRestart)
|
||||
{
|
||||
tOutAutocheck = 60 * utils.CRI("autoRestartTimeoutMin") * (1000 / (utils.CRI("checkPeriod")));
|
||||
tOutAutocheck = DateTime.Now.AddMinutes(utils.CRI("autoRestartTimeoutMin"));
|
||||
lastHlRestart = hlRestart;
|
||||
// fix autorestart...
|
||||
if (hlRestart)
|
||||
|
||||
+6
-6
@@ -23,9 +23,9 @@
|
||||
-->
|
||||
<target xsi:type="File"
|
||||
name="f_base"
|
||||
fileName="${logDir}/${var:codIOB:default=0000}/${shortdate}.log"
|
||||
fileName="${logDir}/${shortdate}.log"
|
||||
layout="${longdate} [${uppercase:${level}}] ${logger:shortName=true}|${message}"
|
||||
archiveFileName="${logDir}/${var:codIOB:default=0000}/${shortdate}.{###}.log"
|
||||
archiveFileName="${logDir}/${shortdate}.{###}.log"
|
||||
archiveNumbering="Sequence"
|
||||
archiveAboveSize="10240000"
|
||||
maxArchiveFiles="60"
|
||||
@@ -33,9 +33,9 @@
|
||||
keepFileOpen="false" />
|
||||
<target xsi:type="File"
|
||||
name="f_error"
|
||||
fileName="${logDir}/${var:codIOB:default=0000}/${shortdate}.log"
|
||||
fileName="${logDir}/${shortdate}_error.log"
|
||||
layout="${longdate} [${uppercase:${level}}] ${logger:shortName=true}|${message}${newline}${exception:format=tostring}"
|
||||
archiveFileName="${logDir}/${var:codIOB:default=0000}/${shortdate}.{###}.log"
|
||||
archiveFileName="${logDir}/${shortdate}.{###}.log"
|
||||
archiveNumbering="Sequence"
|
||||
archiveAboveSize="10240000"
|
||||
maxArchiveFiles="60"
|
||||
@@ -44,9 +44,9 @@
|
||||
<!--Target per asp.net 4.5+ (NON VA con 4.0 common-->
|
||||
<!--<target xsi:type="File"
|
||||
name="f"
|
||||
fileName="${logDir}/${var:codIOB:default=0000}/${shortdate}.log"
|
||||
fileName="${logDir}/${shortdate}.log"
|
||||
layout="${longdate} [${uppercase:${level}}] ${logger:shortName=true}|${message}|${exception:format=tostring}"
|
||||
archiveFileName="${logDir}/${var:codIOB:default=0000}/${shortdate}.{###}.zip"
|
||||
archiveFileName="${logDir}/${shortdate}.{###}.zip"
|
||||
archiveNumbering="Sequence"
|
||||
archiveEvery="Day"
|
||||
archiveOldFileOnStartup="true"
|
||||
|
||||
Reference in New Issue
Block a user