Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Service Question 1

Status
Not open for further replies.

shannanl

IS-IT--Management
Apr 24, 2003
1,071
US
I am trying to make my first service. I called it test service, built and installed it and started it manaully. The service is actually just a timer that writes an entry to the event log every 15 seconds. I start the timer in the service on start part but it does not seem to be working. It never writes to the event log even though it shows the service as running. I used the component timer. is this correct? Any ideas of what I am doing wrong?

Thanks,

Shannan
 
Here is my code :

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.
Timer1.Enabled = True
End Sub

Protected Overrides Sub OnStop()
' Add code here to perform any tear-down necessary to stop your service.
Timer1.Enabled = False
End Sub

Private Sub Timer1_Tick_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
EventLog.WriteEntry("Test Entry")
End Sub
 
I would use System.Timers.Timer instead of the Windows Forms Timer.
 
That did it. Thanks for the help.

Shannan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top