Skip to content

Commit

Permalink
Resolved issue where playback would take a long time to start
Browse files Browse the repository at this point in the history
  • Loading branch information
ajn96 committed Oct 9, 2020
1 parent bf89206 commit a9b7e05
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/DataPlotGUI.vb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Public Class DataPlotGUI
Private Sub ShutDown() Handles Me.Closing
plotTimer.Enabled = False
playBackRunning = False
plotting = False
playBackMutex.WaitOne()
plotMutex.WaitOne()
m_TopGUI.FX3.UserLEDOn()
Expand Down Expand Up @@ -508,8 +509,8 @@ Public Class DataPlotGUI
'Check each box in the reg list
regCnt = 0
For j As Integer = 0 To regView.RowCount() - 1
regFound = headers.Contains(regView.Item("Label", j).Value)
regView.Item("Plot", j).Value = regFound
regFound = headers.Contains(regView.Item("Label", j).Value.ToString())
regView.Item("Plot", j).Value = regFound.ToString()
If regFound Then
regCnt += 1
End If
Expand All @@ -518,19 +519,17 @@ Public Class DataPlotGUI
End Function

Private Sub PlayCSVWorker()
playBackMutex.WaitOne()
Dim waitTime As Long
logTimer.Restart()
Dim timer As New Stopwatch()

playBackMutex.WaitOne()
timer.Start()
While CSVRegData.Count() > 0 And playBackRunning
waitTime = Convert.ToDouble(CSVRegData(0)(0))
While logTimer.ElapsedMilliseconds() < waitTime And playBackRunning
System.Threading.Thread.Sleep(1)
While (timer.ElapsedMilliseconds() < waitTime) And playBackRunning
Thread.Sleep(1)
End While
If Not playBackRunning Then
Exit While
End If
Me.Invoke(New MethodInvoker(AddressOf PlotWork))
If playBackRunning Then Me.Invoke(New MethodInvoker(AddressOf PlotWork))
End While
Me.Invoke(New MethodInvoker(AddressOf EnablePlaybackButtons))
playBackRunning = False
Expand Down

0 comments on commit a9b7e05

Please sign in to comment.