Private oTimer As System.Threading.Timer
Dim running As Boolean = False
#Region "Protected Overrides Sub OnStart(ByVal args() As String)"
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.
'# run the OnTick every 28 seconds
Try
Dim oCallback As New TimerCallback(AddressOf OnTick)
Dim lPeriod As Long = 28000
oTimer = New System.Threading.Timer(oCallback, Nothing, 0, lPeriod)
Catch e As Exception
System.Diagnostics.EventLog.WriteEntry("Service", "there has been an error in Service Start ")
End Try
End Sub
#End Region
#Region "Public Sub OnTick(ByVal state As Object)"
Public Sub OnTick(ByVal state As Object)
'# check if the service isnt tunning
If running = True Then Exit Sub
'# set the service as running
running = True
Try
'# CODE GOES HERE
'########################################################
'########################################################
'# CODE ENDS HERE
Catch ex As Exception
System.Diagnostics.EventLog.WriteEntry("KillConnService", "there has been an error in OnTick " & ex.Message)
Finally
running = False
End Try
End Sub
#End Region
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment