Esempio n. 1
0
        public void StartService(string[] args)
        {
            try
            {
                //Call the routine to read the main configuration xml file for the service
                ReadMainConfiguration();
                XmlSerializer dsers = new XmlSerializer(typeof(TroyFontGlyphMapList));
                FileStream    fss   = new FileStream(serviceConfigFilePath + "TroyFontGlyphConfiguration.xml", FileMode.Open, FileAccess.Read, FileShare.Read);
                tfgml = (TroyFontGlyphMapList)dsers.Deserialize(fss);
                fss.Close();

                //Setup the file watchers for each defined port
                SetupFileWatchers();
            }
            catch (Exception ex)
            {
                //portMonLogging.LogError("Fatal Error in Service Start. " + ex.Message, EventLogEntryType.Error, true);

                EventLog.WriteEntry("Error in Troy Port Monitor Service: " + ex.Message, EventLogEntryType.Error);

                ServiceStop serviceStop  = new ServiceStop(this.ServiceName);
                Thread      workerThread = new Thread(new ThreadStart(serviceStop.Start));
                workerThread.Name = "Troy Service ServiceStop thread";
                workerThread.Start();
            }
        }
Esempio n. 2
0
 protected override void OnStop()
 {
     foreach (FileSystemWatcher fileWatcher in fileWatchers)
     {
         if (fileWatcher != null)
         {
             fileWatcher.EnableRaisingEvents = false;
             fileWatcher.Dispose();
             ServiceStop serviceStop = new ServiceStop(this.ServiceName);
         }
     }
 }