Skip to content
This repository was archived by the owner on Feb 19, 2023. It is now read-only.

Commit 44662d5

Browse files
committed
fix: do not run before ready
1 parent 2eed514 commit 44662d5

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

frmMain.vb

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,7 +1824,7 @@ LocalErrorHandler:
18241824
'configure the operator message box
18251825
Me.rtbOperatorMessage.Text = LangLookup(modLocalization.txslLangIndex.gnReadyToTest)
18261826

1827-
1827+
_readyToRunEvent.Set()
18281828
End Sub
18291829

18301830
Private Sub InitSerialInput()
@@ -2102,11 +2102,11 @@ LocalErrorHandler:
21022102
Me.Cursor = mnOldMousePointer
21032103
ConfigButtonsBeforeRun()
21042104

2105-
If _client.Connected Then
2106-
FixBox.BackColor = IIf(_client.Report(), Color.Red, Color.Yellow)
2105+
If _tcpClient.Connected Then
2106+
FixBox.BackColor = IIf(_tcpClient.Report(), Color.Red, Color.Yellow)
21072107
End If
21082108
InitSerialInput()
2109-
_pause.Set()
2109+
_testDoneEvent.Set()
21102110
Exit Sub
21112111

21122112
LocalErrorHandler:
@@ -2325,21 +2325,25 @@ LocalErrorHandler:
23252325
thread.Start()
23262326
End Sub
23272327

2328-
ReadOnly _client As New TcpClient()
2329-
Dim _pause As New Threading.AutoResetEvent(False)
2328+
ReadOnly _tcpClient As New TcpClient()
2329+
ReadOnly _readyToRunEvent As New AutoResetEvent(False)
2330+
ReadOnly _testDoneEvent As New AutoResetEvent(False)
23302331
Private Sub BackgroundThread()
2331-
If Not _client.Connect() Then
2332+
If Not _tcpClient.Connect() Then
23322333
Return
23332334
End If
2335+
23342336
SysBox.BackColor = Color.Green
2337+
_readyToRunEvent.WaitOne()
23352338

23362339
While True
2337-
If _client.Check() Then
2340+
If _tcpClient.Check() Then
23382341
FixBox.BackColor = Color.Green
23392342
Invoke(Sub()
23402343
cmdRun_Click(cmdRun, New System.EventArgs)
23412344
End Sub)
2342-
_pause.WaitOne()
2345+
_testDoneEvent.WaitOne()
2346+
_testDoneEvent.Reset()
23432347
End If
23442348
Thread.Sleep(500)
23452349
End While

0 commit comments

Comments
 (0)