I\'m using the System.Timers.Timer class to create a timer with an Timer.Elapsed event. The thing is the Timer.Elapsed event is fired
I have implemented in VB.NET with AddHandler
Public Class clsMain Inherits ServiceBase
Protected Overrides Sub OnStart(ByVal args() As String)
' Add code here to start your service. This method should set things
' in motion so your service can do its work.
gTimer.Interval = 1000
gTimer.Enabled = True
AddHandler gTimer.Elapsed, AddressOf gTimer_Elapsed
End Sub
'When the timer is elapsed this event will be fired
Protected Sub gtimer_Elapsed(ByVal source As Object, ByVal e As ElapsedEventArgs)
'Stop the timer and do some work
gTimer.Stop()
'Custom code
'Here
'Start to raise the elapsed event again
gTimer.Start()
End Sub
End Class