Beispiel #1
0
 protected override void OnStart(string[] args)
 {
     timer.Interval = 500;                                                                                                                //number in milisecinds
     logger.Info(String.Format("Service {0} has been started at {1}, Timer set to {2}", this.ServiceName, DateTime.Now, timer.Interval)); // Manual Log
     try
     {
         logger.Info(String.Format("Running CamstarExtractor"));                      // Manual Log
         csx = new CamstarExtractor();
         logger.Info(String.Format("CamstarExtractor object created successfully.")); // Manual Log
     }
     catch (Exception e)
     {
         logger.Fatal(String.Format("Service {0} has thrown an exception! {1} at {2}. Shuttting down.", this.ServiceName, e.Message, DateTime.Now));               // Manual Log
         ServiceController svc = new ServiceController("CamstarExtractService");
         svc.Stop();
     }
     logger.Info("Service is started at " + DateTime.Now);
     timer.Elapsed += new ElapsedEventHandler(OnElapsedTime);
     timer.Enabled  = true;
 }
Beispiel #2
0
 protected override void OnStop()
 {
     logger.Info(String.Format("Service {0} is stopping at {1}", this.ServiceName, DateTime.Now));               // Manual Log
     csx = null;
     logger.Info("Service is stopped at " + DateTime.Now);
 }