问题
I'm working on a Windows Form Desktop application using VB.Net and there is one form which acts as a dashboard having 3 timers where each timer is responsible for its own specific part of the dashboard. The issue is with one timer where that timer should call a user-defined Sub which updates the database, but sometimes the timer gets skipped or ignored, which results in missing dashboard information. I tried using sleep and then Async Await to fix the problem, but the behavior is still the same.
here is a a similar code inside that timer.
Private Sub timer1_Tick(ByVal sender As Object, ByVal e As EventArgs)
If myQueue.Count > 0 Then
label1.Text = myQueue.Peek().ToString()
x -= 1
If x = 10 Then
label1.Visible = False
End If
If x = 8 Then
label1.Visible = True
End If
If x = 6 Then
label1.Visible = False
End If
If x = 4 Then
label1.Visible = True
End If
If x = 2 Then
label1.Visible = False
End If
If x = 0 Then
label1.Visible = True
x = 12
myQueue.Dequeue()
Call Sub1(Par1)
End If
End If
End Sub
来源:https://stackoverflow.com/questions/59741233/timers-are-interleaved-dashboard-update-event-getting-skipped