I got a Timer With Interval = 1
VB.NET定時器間隔1 = 1毫秒?
區間1 = 1毫秒?
如果間隔1不爲1毫秒,
所以,告訴我它控制間隔爲1ms
代碼:
Imports System.Globalization
Public Class Form1
'Default Time To Start From
Dim time As String = "00:00:00,000" 'Start From Here
'Label
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
Timer1.Start() 'Run The Timer On Click
End Sub
'TIMER
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
'Timer Interval = 1
Dim ci = CultureInfo.InvariantCulture
Dim original As TimeSpan = TimeSpan.ParseExact(time, "hh\:mm\:ss\,fff", ci) 'ParseExact
Dim difference As TimeSpan = TimeSpan.FromMilliseconds(1) ' = 1 Millisecond
Dim final = original
final = original + difference ' connect between original to difference !(00:00:00,000 + 1 MS = 00:00:00,001)!
Dim output As String = final.ToString("hh\:mm\:ss\,fff", ci) 'convert to the format ( = 00:00:00,001 ) (Back It To The Right Format)
time = output '!!Update!! the Time String from 00:00:00,000 To 00:00:00,001 |||| And in the Next Time 00:00:00,001 + 1 = 00:00:00,002
Label1.Text = time 'Show the Time String in the label
End Sub
End Class
正如你看到的 - 林期運用定期定時帶間隔1 ,
但我認爲它worng,因爲計時器不包括毫秒
如果你有一個dvice,告訴我。
[從MSDN](http://msdn.microsoft.com/en-us/library/system.windows.forms.timer.aspx)Windows窗體計時器組件是單線程的,並且是有限的精確到55毫秒。如果您需要更高精度的多線程定時器,請使用System.Timers命名空間中的Timer類。「 – Steve
」您有System.Timers的示例嗎?我需要定時器(1ms) – nnm
向我們展示創建定時器並開始計時的代碼。它可能在'Main'中。它會包含類似於'Timer1.Interval = 1;'的內容。 –