Reputation: 493
I am trying to use a Timer control in my console application.
Friend WithEvents XTIMER As System.Windows.Forms.Timer
I am setting all its properties. I have set the interval to 15000 ms. But even when I set the Enabled state of the timer control to be true, the tick event is not firing. Can any one help me out please?
Upvotes: 6
Views: 45092
Reputation: 11773
Module Module1
Sub Main()
aTimer.AutoReset = True
aTimer.Interval = 2000 '2 seconds
AddHandler aTimer.Elapsed, AddressOf tick
aTimer.Start()
Console.ReadKey()
End Sub
Dim aTimer As New System.Timers.Timer
Private Sub tick(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs)
Console.WriteLine("tick")
End Sub
End Module
Upvotes: 13
Reputation: 12613
Import the System.Windows.Forms
reference and use the Timer
class.
Upvotes: 0
Reputation: 4592
Use System.Timers.Timer instead. Here's a very good comparison of the timer classes.
Upvotes: 1