protected override void OnStart(string[] args) { Lithnet.MetadirectoryServices.Resolver.MmsAssemblyResolver.RegisterResolver(); try { Logger.LogPath = this.LogFile; Logger.LogLevel = this.LogLevel; Logger.WriteLine("Service starting"); this.ConnectToDatabase(); this.LoadConfiguration(); this.StartSyncServiceHost(); this.StartAcmaServiceHost(); this.StartFileSystemWatcher(); AcmaExternalExitEvent.StartEventQueue(); Logger.WriteLine("Service started"); } catch (Exception ex) { Logger.WriteLine("An error occurred while starting the service"); Logger.WriteException(ex); throw; } }
protected override void OnStop() { Logger.WriteLine("Service shutting down"); if (this.syncServiceHost != null) { this.syncServiceHost.Close(); this.syncServiceHost = null; } if (this.acmaServiceHost != null) { this.acmaServiceHost.Close(); this.acmaServiceHost = null; } if (this.configFileWatcher != null) { this.configFileWatcher.EnableRaisingEvents = false; } AcmaExternalExitEvent.CompleteEventQueue(); }