Timers are interleaved, Dashboard update event getting skipped

折月煮酒 提交于 2020-01-22 04:00:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!