- migliorata gestione riavvio thread

This commit is contained in:
Emmanuele Sassi
2023-05-17 12:04:24 +02:00
parent 9808f32544
commit 44e62b8798
+11 -4
View File
@@ -237,7 +237,8 @@ Public Class ProcMan
' se qualche processo in stop, lo faccio ripartire
For ThreadIndex = 0 To ThreadList.Count - 1
Dim Thread = ThreadList(ThreadIndex)
If Thread.ThreadState = ThreadState.Stopped Then
If Thread.ThreadState = ThreadState.Stopped OrElse Thread.ThreadState = ThreadState.Aborted OrElse
Thread.ThreadState = ThreadState.Suspended Then
Thread.Abort()
Dim ThreadId As Integer = ThreadIndex
Thread = New Thread(Sub()
@@ -763,12 +764,12 @@ Public Class ProcMan
' controllo se cambiato il num thread
If numReq <> m_MaxCamInstances Then
stopAllThreads()
Thread.Sleep(100)
SetMaxCamInstances(numReq)
'startAllThreads()
End If
End Sub
Private isUpdatingThreads As Boolean = False
''' <summary>
''' Esecuzione update display lista stato threads
@@ -916,9 +917,15 @@ Public Class ProcMan
Private Sub CheckStartAutoRestart()
TimerCheck.Enabled = chkAutoRestart.Checked
If chkAutoRestart.Checked Then
If m_ExecutionThread.ThreadState = ThreadState.Aborted OrElse m_ExecutionThread.ThreadState = ThreadState.Stopped OrElse
m_ExecutionThread.ThreadState = ThreadState.Suspended Then
stopAllThreads()
Thread.Sleep(200)
m_ExecutionThread.Abort()
Thread.Sleep(200)
startAllThreads()
End If
TimerCheck.Start()
Task.Delay(500)
startAllThreads()
Else
TimerCheck.Stop()
End If