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

Commit 69573d6

Browse files
committed
fix: pause thread when testing
1 parent ae228d7 commit 69573d6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

frmMain.vb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2101,6 +2101,7 @@ LocalErrorHandler:
21012101
FixBox.BackColor = IIf(_client.Report(), Color.Red, Color.Yellow)
21022102
End If
21032103
InitSerialInput()
2104+
_pause.Set()
21042105
Exit Sub
21052106

21062107
LocalErrorHandler:
@@ -2315,9 +2316,9 @@ LocalErrorHandler:
23152316
cmdLoadTestplan.Focus()
23162317
End If
23172318

2318-
Dim thread As New Thread(AddressOf BackgroundThread)
2319-
thread.Start()
2319+
_thread.Start()
23202320
End Sub
2321+
ReadOnly _thread As New Thread(AddressOf BackgroundThread)
23212322

23222323
Private Sub InitSerialInput()
23232324
' Set focus to the input box and clear it
@@ -2326,6 +2327,7 @@ LocalErrorHandler:
23262327
End Sub
23272328

23282329
ReadOnly _client As New TcpClient()
2330+
Dim _pause As New Threading.AutoResetEvent(False)
23292331
Private Sub BackgroundThread()
23302332
If Not _client.Connect() Then
23312333
Return
@@ -2338,6 +2340,7 @@ LocalErrorHandler:
23382340
Invoke(Sub()
23392341
cmdRun_Click(cmdRun, New System.EventArgs)
23402342
End Sub)
2343+
_pause.WaitOne()
23412344
End If
23422345
Thread.Sleep(500)
23432346
End While

0 commit comments

Comments
 (0)