[thelist] Windows Service: Timer1_Tick won't Tick

Casey Crookston caseyc at IntelliSoftmn.com
Tue Jun 12 14:30:32 CDT 2007

I'm trying my hand for the first time at creating a windows service.  I'm creating it in vb.net 2005.  Should be simple enough... it consists only of a timer set at an interval of 10,000 (10 seconds), and a write to the event log every time the timer ticks - or hits ten seconds.  When I start and stop the service, it records these events in the event viewer, but the every-10-second events are not being recorded.  Here's the entire code.  Any ideas?
Thanks in advance!
Public Class STORK_Messenger

Protected Overrides Sub OnStart(ByVal args() As String)
     Timer1.Enabled = True
End Sub

Protected Overrides Sub OnStop()
     Timer1.Enabled = False
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

Dim STORK_Messenger_Log As New EventLog() ' create a new event log 
If Not STORK_Messenger_Log.SourceExists("STORK_Messenger") Then
     STORK_Messenger_Log.CreateEventSource("STORK_Messenger", "Myservice Log") ' Create Log 
End If

STORK_Messenger_Log.Source = "STORK_Messenger"
STORK_Messenger_Log.WriteEntry("STORK_Messenger Log", "This is log on " & CStr(TimeOfDay), EventLogEntryType.Information)

End Sub

End Class

More information about the thelist mailing list