Merge branch 'develop'

This commit is contained in:
Samuele E. Locatelli
2020-02-04 18:44:53 +01:00
2 changed files with 84 additions and 25 deletions
Binary file not shown.
+84 -25
View File
@@ -72,6 +72,10 @@ namespace IOB_MAN
/// semaforo check...
/// </summary>
protected bool checkRunning = false;
protected bool doTaskRun = false;
protected bool doParallel = true;
public IOBManPanel()
{
InitializeComponent();
@@ -358,12 +362,16 @@ namespace IOB_MAN
updateProgBar();
if (!checkRunning)
{
chekProcessStatusAsync();
if (doTaskRun)
{
checkProcessStatusAsync();
}
else
{
checkProcessStatus();
}
checkWatchdog();
}
else
{
}
}
/// <summary>
/// Controllo periodico dei processi DA RIATTIVARE
@@ -424,14 +432,35 @@ namespace IOB_MAN
/// <summary>
/// Controllo periodico dei processi attivi
/// </summary>
private async Task chekProcessStatusAsync()
private void checkProcessStatus()
{
chekMult--;
if (chekMult < 0)
{
checkRunning = true;
// reset variabili appoggio
chekMult = utils.CRI("chekMult");
checkRunning = true;
// eseguo task!
checkRunningchild();
updateStatus();
checkRunning = false;
}
}
/// <summary>
/// Controllo periodico dei processi attivi
/// </summary>
private async Task checkProcessStatusAsync()
{
chekMult--;
if (chekMult < 0)
{
// reset variabili appoggio
chekMult = utils.CRI("chekMult");
checkRunning = true;
// eseguo task!
await Task.Run(() => checkRunningchild());
updateStatus();
checkRunning = false;
}
}
@@ -451,39 +480,69 @@ namespace IOB_MAN
private void checkRunningchild()
{
List<iobAdapt> item2rem = new List<iobAdapt>();
IList<iobAdapt> allItems = (IList<iobAdapt>)ElencoIOB.List;
bool needRem = false;
numProcRunning = numProcAvviati;
// 2020.02.01 passato chiamata specifica x leggere in 1 sola volta TUTTO elenco processi (x nome)...
Process[] processList = Process.GetProcessesByName(TargetName);
// ciclo
foreach (iobAdapt item in ElencoIOB.List)
if (doParallel)
{
// verifico se esista il processo...
try
// ciclo
Parallel.ForEach(allItems, item =>
{
Process p = myGetProcByID(processList, item.pID);
needRem = p.HasExited;
// verifico se esista il processo...
try
{
Process p = myGetProcByID(processList, item.pID);
needRem = p.HasExited;
}
catch
{
needRem = true;
}
if (needRem)
{
item2rem.Add(item);
item.isRunning = false;
numProcRunning--;
}
else
{
item.isRunning = true;
}
}
catch
);
}
else
{
foreach (iobAdapt item in allItems)
{
needRem = true;
}
if (needRem)
{
item2rem.Add(item);
item.isRunning = false;
numProcRunning--;
}
else
{
item.isRunning = true;
// verifico se esista il processo...
try
{
Process p = myGetProcByID(processList, item.pID);
needRem = p.HasExited;
}
catch
{
needRem = true;
}
if (needRem)
{
item2rem.Add(item);
item.isRunning = false;
numProcRunning--;
}
else
{
item.isRunning = true;
}
}
}
// aggiorno datagrid!
dgvManagedItems.Invalidate();
updateStatus();
}
private void IOBManPanel_FormClosing(object sender, FormClosingEventArgs e)