cyclonebri
Well-known member
Hello, I have written two services that I need, both of which query a webservice and then write the results to a SQL database (different DBs for each service). Both services are written in VB.net because of the web service interface that I was given also being in VB.net. Both services basically need to do the same thing. Start, run as a service, every fifteen minutes they need to trigger the classes that I have written to do all the web service and database interaction. I am positive beyond any doubt that the classes are working exactly as they are supposed to, as I placed them in dummy apps and tested all the class code. The problem I have is that I used a timer to have the thing run every 15 minutes, and after installing the application, the timer doesnt ever run. Its as if the timer is not allowed within a service at all, but I know that it is. Anyway, if someone could help me out with why this might be happening, I would sure appreciate it. My code is very simple, it looks like this:
The timer is set to enabled in the designer and is not ever disabled. If I set it to enabled in the service code it makes no difference, it still does not run.
myValueReader is an object that is global and is accessing my class. It is not causing any problems and is working like it should.
Thanks in advance for any help offered!
Brian
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.
Dim myServiceOutFile As System.IO.StreamWriter = New System.IO.StreamWriter("C:\SERVICELOG_START.dat")
Try
myServiceOutFile.WriteLine("SERVICE STARTED AT: " & System.DateTime.Now)
Catch ex As Exception
myServiceOutFile.WriteLine(ex.Message)
Finally
myServiceOutFile.Close()
End Try
m_stupidcount = 0
End Sub
Protected Overrides Sub OnStop()
Add code here to perform any tear-down necessary to stop your service.
Dim myServiceOutFile As System.IO.StreamWriter = New System.IO.StreamWriter("C:\SERVICELOG_STOP.dat")
Try
myKioskValueReader = Nothing
myServiceOutFile.WriteLine("SERVICE STOPPED AT: " & System.DateTime.Now)
Catch ex As Exception
myServiceOutFile.WriteLine(ex.Message)
Finally
myServiceOutFile.Close()
End Try
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim success As Boolean
Try
so the log file will not be opening and closing all the time, and it can be proven that this is running
If m_stupidcount = 0 Then
Dim myServiceOutFile As System.IO.StreamWriter = New System.IO.StreamWriter("C:\SERVICELOG_TIMER.dat")
Try
myServiceOutFile.WriteLine("IN THE TIMER: " & System.DateTime.Now)
Catch ex As Exception
myServiceOutFile.WriteLine(ex.Message)
Finally
myServiceOutFile.Close()
m_stupidcount += 1
End Try
End If
success = myValueReader.Query_RPM()
EventLog.WriteEntry(success)
Catch ex As System.Exception
Try
success = myValueReader.Query_RPM()
Catch ex2 As Exception
do nothing
Finally
do nothing
End Try
Finally
do nothing
End Try
End Sub
The timer is set to enabled in the designer and is not ever disabled. If I set it to enabled in the service code it makes no difference, it still does not run.
myValueReader is an object that is global and is accessing my class. It is not causing any problems and is working like it should.
Thanks in advance for any help offered!
Brian