Public Class Main Inherits WindowsService Shared Sub Main(ByVal toArgs As String()) Startup(toArgs, New Main(), True) End SubAnd, the base class:
Imports System.ServiceProcess Public Class WindowsService Inherits ServiceBase Public oTimer As New System.Timers.Timer(5000) Protected Shared Sub Startup(toArgs As String(), toWindowsService As WindowsService, tlInteractiveWait As Boolean) toWindowsService.OnStart(toArgs) End Sub Protected Overrides Sub OnStart(ByVal toArgs As String()) MyBase.OnStart(toArgs) ' Define the timer AddHandler oTimer.Elapsed, AddressOf ServiceTimer ' Start the timer oTimer.Enabled = True System.Windows.Forms.MessageBox.Show("End") End Sub Protected Overrides Sub OnStop() MyBase.OnStop() End Sub Private Sub ServiceTimer(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) End Sub