Hi,
I was wondering in how to do a Win Service that will execute at certain periods of time, and the way I achieved it was doing this.
Using VS selecting a project of type Windows Service a class is created with OnStart and OnStop Routines, so at this point the service only execute a bunch of code in the OnStart Routine when is started .
What we are going to do is declare some var of type Timers.Timer
Public T As New Timers.Timer(60000)
60000 is the time in milliseconds that the service is going to execute some code.
Now we must associate an event Handler to the OnStart Sub with the elapsed event
Protected Overrides Sub OnStart(ByVal args() As String)
AddHandler T.Elapsed, AddressOf T_Tick
End Sub
We must create the Method T_Tick wich has the code to be executed each 60 seconds.
Private Sub T_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
'...
'...
'...
End Sub
No hay comentarios:
Publicar un comentario