Posts Tagged ‘Timer’
How to use Timer in Windows Service
Posted by: admin in .NET, VB.Net, Window Services on February 28th, 2009
You cannot use Timer Control in windows service it is because Timer Control is located at System.Windows.Forms.
Instead, use server timers from Timer namespace. To do this,
Friend WithEvents mTimer as New Timer.Timer
Protected Overrides Sub OnStart(ByVal args() As String)
mTimer.Interval = 6000 ’6 seconds
mTimer.Enable = true
End Sub
Private Sub mTimer_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles mTimer.Elapsed
‘Put your code here to execute
End Sub