- gestiti mutex con nome da ini per distinguere istanze

- spostata inizializzazione oggetto web in load
- corretti errori i n avvio per oggetti non inizializzati
- spostata path dell'Engine in file ini
This commit is contained in:
Emmanuele Sassi
2024-01-05 09:20:16 +01:00
parent cd32764c1e
commit f3810fa708
2 changed files with 23 additions and 7 deletions
+2
View File
@@ -35,8 +35,10 @@ Public Module ConstIni
Public Const K_INSTANCES As String = "Instances"
Public Const K_COMMANDLOG As String = "CommandLog"
Public Const K_STARTINSTANCES As String = "StartInstances"
Public Const K_PROCESSPATH As String = "ProcessPath"
Public Const K_PROCESSATSTART As String = "ProcessAtStart"
Public Const K_BASEURL As String = "BaseUrl"
Public Const K_BASEIP As String = "BaseIp"
Public Const K_MUTEXNAME As String = "MutexName"
End Module
+21 -7
View File
@@ -48,8 +48,10 @@ Public Class ProcMan
Dim codPost As String = "WRK001"
Dim sEgtEnginePath As String = ""
' nome macchina calcolo
Dim currWDC As WDC = New WDC(baseIp, baseUrl, codPost)
Dim currWDC As WDC
Dim idxSim As Integer = 0
@@ -278,9 +280,9 @@ Public Class ProcMan
' ThreadProcessState = ThreadDataList(ThreadIndex).Process.HasExited
'End If
ThreadCurrentStatusList.Items.Add(New ListViewItem(New String() {ThreadIndex,
ThreadList(ThreadIndex).ThreadState.ToString(),
If(Not IsNothing(ThreadList(ThreadIndex)), ThreadList(ThreadIndex).ThreadState.ToString(), ""),
ThreadProcessState,
ThreadDataList(ThreadIndex).ThreadOperation.ToString()}))
If(Not IsNothing(ThreadDataList(ThreadIndex)), ThreadDataList(ThreadIndex).ThreadOperation.ToString(), "")}))
Else
ThreadCurrentStatusList.Items.Add(New ListViewItem(New String() {ThreadIndex,
"nothing"}))
@@ -319,6 +321,7 @@ Public Class ProcMan
End Sub
Private Sub DisplayQueueStatus()
If IsNothing(currWDC) Then Return
Dim queueStatus As New Dictionary(Of String, Long)
queueStatus = currWDC.queueStatus
Dim sb As StringBuilder
@@ -874,7 +877,6 @@ Public Class ProcMan
HistoryThreadDataList.Add(CurrThreadStat)
MyThreadData.SetThreadStat(CurrThreadStat)
Dim sDrive As String = "c" ' If(ThreadIndex Mod 2 = 0, "A", "B")
Dim sExePath As String = sDrive & ":\EgtProg\EgtEngine\EgtEngineR64.exe"
Dim sCurrDdfDir As String = sDrive & ":\EgtData\WebDoor\Ddf"
Dim stopWatch As New Stopwatch()
Dim lExeTime As Long = 0
@@ -882,7 +884,7 @@ Public Class ProcMan
' avvio processo
Dim Proc As Process = New Process()
Proc.StartInfo.FileName = sExePath
Proc.StartInfo.FileName = sEgtEnginePath
Proc.StartInfo.RedirectStandardInput = True
Proc.StartInfo.RedirectStandardOutput = True
Proc.StartInfo.Arguments = ThreadIndex.ToString() & " """ & sDrive & ":\EgtData\WebDoor\TestPipe.lua"""
@@ -1328,7 +1330,15 @@ Public Class ProcMan
' leggo sorgente richieste rest da ini
GetPrivateProfileString(S_GENERAL, K_BASEIP, "", baseIp, m_IniFilePath)
GetPrivateProfileString(S_GENERAL, K_BASEURL, "", baseUrl, m_IniFilePath)
' inizializzo oggetto web
currWDC = New WDC(baseIp, baseUrl, codPost)
txtNumThread.Text = GetPrivateProfileInt(S_GENERAL, K_STARTINSTANCES, 1, m_IniFilePath).ToString()
' recupero path EgtEngine
GetPrivateProfileString(S_GENERAL, K_PROCESSPATH, "", sEgtEnginePath, m_IniFilePath)
MyBase.Text = baseUrl
End Sub
Dim m_objMutex As Mutex
@@ -1340,7 +1350,9 @@ Public Class ProcMan
Private Sub ManageInstance()
Dim bCreated As Boolean
Try
m_objMutex = New Mutex(False, "Global\WebDoorCreator.CamSrv", bCreated)
Dim sMutexName As String = "Global\WebDoorCreator.CamSrv"
GetPrivateProfileString(S_GENERAL, K_MUTEXNAME, sMutexName, sMutexName, m_IniFilePath)
m_objMutex = New Mutex(False, sMutexName, bCreated)
Catch
bCreated = False
End Try
@@ -1417,7 +1429,9 @@ Public Class ProcMan
End Sub
Private Sub TimerResetProcessing_Tick(sender As Object, e As EventArgs) Handles TimerResetProcessing.Tick
currWDC.ResetQueueProcessing()
If Not IsNothing(currWDC) Then
currWDC.ResetQueueProcessing()
End If
End Sub
#End Region