是否可以同时运行两个定时器?

时间:2014-01-15 19:37:51

标签: visual-studio-2010 vba

是否可以同时运行两(2)个计时器?我的计时器1是一个倒数计时器,从15:00:00(秒表)计数,我希望我的计时器2每隔10秒更改一次标签文本,就像这样,

        Dim StopWatch As New Stopwatch
        Dim CountDown As TimeSpan

Public Sub ClientDasboard_Load ......

        StopWatch.Start()
        synchroUpdate.Enabled = True
        synchroUpdate.Start()
        Dim numSecs As Integer
        Integer.TryParse(UserTotal.Text, numSecs)
        CountDown = TimeSpan.FromSeconds(numSecs)
End Sub


        Private Sub synchro_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles synchroUpdate.Tick
    synchroUpdate.Interval = 100     
    Dim elaps As TimeSpan = CountDown - StopWatch.Elapsed
    DispElaps(elaps, Label2)       
End Sub


       Private Sub synchroUpdate_Tick_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
    synchroUpdate.Interval = 1000
         If x = 10 Then
             Label2.Text = "Saved!"
             Label2.Text = ""
             x = 0
         Else
             x += 1
         End If
      End Sub

我可以同时运行它们吗?或者合并?我很傻。

0 个答案:

没有答案