代码之家  ›  专栏  ›  技术社区  ›  James.Alocard

使计时器间隔小于1毫秒.Net

  •  -1
  • James.Alocard  · 技术社区  · 7 年前

    我试着用小于1毫秒的时间间隔来计时。

    我的尝试:

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Timer1.Interval = 0000001
        Timer1.Start()
    End Sub
    
      Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        ProgressBar1.Increment(+1)
        If ProgressBar1.Value = 100 Then
            Timer1.Stop()
            ProgressBar1.Value = 0
            MessageBox.Show("Done, 1 Ms")
        End If
    End Sub
    

    我的主要目的是使计时器以纳秒的速度运行,以使标签文本的增加速度(+1)快于1毫秒。我知道它每1秒钟将增加(+1000),但我需要使它快于1毫秒。

    1 回复  |  直到 7 年前
        1
  •  0
  •   Impurity    7 年前

    不幸的是,这是不可能的。见 this msdn post 更多关于这个问题的阅读。这个 StopWatch 测量 Timer .

    推荐文章