A
anthony
Hi, there is sth i am not sure, i looked at the help in vb.net for creating
timer on the fly (see below).
Since the event would happen 10sec later, I cannot destroy the timer right
away (or can I? or will VB.net destroy automatically?), I can do it after
the event is fired, but the timer is not in scope in the event subroutine.
If I leave it as is, if the application continue to fire the timer over
time, then it would continue to consume system resource?
Public Shared Sub Main()
' Create a new Timer with Interval set to 10 seconds.
Dim aTimer As New System.Windows.Forms.Timer(10000)
AddHandler aTimer.Elapsed, AddressOf OnTimedEvent
' Only raise the event the first time Interval elapses.
aTimer.AutoReset = False
aTimer.Enabled = True
Console.WriteLine("Press 'q' to quit the sample.")
While Console.Read() <> CInt("q")
End While
End Sub
' Specify what you want to happen when the event is raised.
Private Shared Sub OnTimedEvent(source As Object, e As ElapsedEventArgs)
Console.WriteLine("Hello World!")
End Sub
timer on the fly (see below).
Since the event would happen 10sec later, I cannot destroy the timer right
away (or can I? or will VB.net destroy automatically?), I can do it after
the event is fired, but the timer is not in scope in the event subroutine.
If I leave it as is, if the application continue to fire the timer over
time, then it would continue to consume system resource?
Public Shared Sub Main()
' Create a new Timer with Interval set to 10 seconds.
Dim aTimer As New System.Windows.Forms.Timer(10000)
AddHandler aTimer.Elapsed, AddressOf OnTimedEvent
' Only raise the event the first time Interval elapses.
aTimer.AutoReset = False
aTimer.Enabled = True
Console.WriteLine("Press 'q' to quit the sample.")
While Console.Read() <> CInt("q")
End While
End Sub
' Specify what you want to happen when the event is raised.
Private Shared Sub OnTimedEvent(source As Object, e As ElapsedEventArgs)
Console.WriteLine("Hello World!")
End Sub