// Remember ... this is the ONLY class that I inherit from ServiceBase, and it lives in the EXE public partial class MyService : ServiceBase { // These classes are defined elsewhere, in my Framework DLLs // They are not sub-classed from ServiceBase, in fact they are not sub-classed at all // They are just plain old classes static MyTransferClass Transfer; static MyHostClass Host; public MyService() { this.CanStop = true; this.CanShutdown = true; this.CanPauseAndContinue = false; } protected override void OnStart(string[] args) { // startup code here Transfer = new MyTransferClass(); Host = new MyHostClass(); Transfer.Start(); Host.Start(); //Console.WriteLine("Done With OnStart"); } protected override void OnStop() { // stop code here if (Host != null) Host.Stop(); if (Transfer != null) Transfer.Stop(); } protected override void OnShutdown() { // TODO: There may be a bug in the .NET Framework in that this method // is not being called on system shutdown for SYSTEM account services. // Not sure when/if it will be fixed, but I'm putting code here to stop // stuff on the off-chance that it will be called eventually. // stop code here } // These 2 methods are only used when not runnning as a Service, for testing from a Console window. public void Start() { this.OnStart(null); } public void Stop() { this.OnStop(); } }Is this helping any????
>Imports System.ServiceProcess > >Public Class Main > Inherits WindowsService > > Public Sub New() > End Sub > > Shared Sub Main() > > ' If this from the Windows Service > If Not Environment.UserInteractive Then > Dim loWindowsService As ServiceBase() > loWindowsService = New ServiceBase() {New WindowsService()} > ServiceBase.Run(loWindowsService) > Else > oWindowsService = New WindowsService() > oWindowsService.Start() > Console.ReadLine() > oWindowsService.Stop2() > End If > > End Sub > > Public Overrides Function Initialize() As Boolean > oApp.cMemberTable = "Member" > Return True > End Function >>
> ' Allow the client to set up custom code in the initialization > Public Overridable Function Initialize() As Boolean > Return True > End Function >>