Windows Service with timer

From: Henrik H (HenrikH_at_discussions.microsoft.com)
Date: 08/25/04


Date: Wed, 25 Aug 2004 04:07:04 -0700

Hi all!

I have a Windows service, where I want to use a timer.. But i does not seems
work?? It does not catch the Timer1.tick event ??? But the code works on a
form???
Can anyone help me, please??

"Onstart" - I set:
        Timer1.Interval = 5000
        Timer1.Enabled = True
        Timer1.Start()

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
        Dim MyLog As New EventLog ' create a new event log
        ' Check if the the Event Log Exists
        If Not MyLog.SourceExists("Service") Then
            MyLog.CreateEventSource("Service", "Service Log") ' Create Log
        End If
        MyLog.Source = "Service"

        ' Write to the Log
        MyLog.WriteEntry("Service Log", "This is log on " & _
        CStr(TimeOfDay), EventLogEntryType.Information)

    End Sub