home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic .NET - Read Less - Learn More / Visual_Basic.NET_Read_Less_Learn_More_Richard_Bowman_Visual_2002.iso / Resources / Code / Ch11-InstallWindowsService / Service1.vb < prev    next >
Text File  |  2001-09-02  |  2KB  |  56 lines

  1. Imports System.ServiceProcess
  2.  
  3. Public Class Service1
  4.     Inherits System.ServiceProcess.ServiceBase
  5.  
  6. #Region " Component Designer generated code "
  7.  
  8.     Public Sub New()
  9.         MyBase.New()
  10.  
  11.         ' This call is required by the Component Designer.
  12.         InitializeComponent()
  13.  
  14.         ' Add any initialization after the InitializeComponent() call
  15.  
  16.     End Sub
  17.  
  18.     ' The main entry point for the process
  19.     Shared Sub Main()
  20.         Dim ServicesToRun() As System.ServiceProcess.ServiceBase
  21.  
  22.         ' More than one NT Service may run within the same process. To add
  23.         ' another service to this process, change the following line to
  24.         ' create a second service object. For example,
  25.         '
  26.         '   ServicesToRun = New System.ServiceProcess.ServiceBase () {New Service1, New MySecondUserService}
  27.         '
  28.         ServicesToRun = New System.ServiceProcess.ServiceBase () {New Service1}
  29.  
  30.         System.ServiceProcess.ServiceBase.Run(ServicesToRun)
  31.     End Sub
  32.  
  33.     'Required by the Component Designer
  34.     Private components As System.ComponentModel.Container
  35.  
  36.     ' NOTE: The following procedure is required by the Component Designer
  37.     ' It can be modified using the Component Designer.  
  38.     ' Do not modify it using the code editor.
  39.     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
  40.         components = New System.ComponentModel.Container()
  41.         Me.ServiceName = "Service1"
  42.     End Sub
  43.  
  44. #End Region
  45.  
  46.     Protected Overrides Sub OnStart(ByVal args() As String)
  47.         ' Add code here to start your service. This method should set things
  48.         ' in motion so your service can do its work.
  49.     End Sub
  50.  
  51.     Protected Overrides Sub OnStop()
  52.         ' Add code here to perform any tear-down necessary to stop your service.
  53.     End Sub
  54.  
  55. End Class
  56.