protected override void OnStop()
 {
     try
     {
         eventLog.WriteEntry("Stopping SyncServerFiles Service");
         _syncServerFiles = null;
         _syncServerFilesCancellation.Cancel();
         _updateOrderTask.Wait();
         eventLog.WriteEntry("Stopped SyncServerFiles Service");
     }
     catch (Exception ex)
     {
         eventLog.WriteEntry(ex.Message + " -ST- " + ex.StackTrace, EventLogEntryType.Error);
     }
 }
 protected override void OnStart(string[] args)
 {
     try
     {
         eventLog.WriteEntry("Starting SyncServerFiles Service");
         InitializeSettingsService.InitializeConstants();
         _syncServerFiles             = new SyncServerFilesService(eventLog);
         _syncServerFilesCancellation = new CancellationTokenSource();
         _updateOrderTask             = Task.Run(() => DoSyncServerFilesTask(_syncServerFilesCancellation.Token));
         eventLog.WriteEntry("Started SyncServerFiles Service");
     }
     catch (Exception ex)
     {
         eventLog.WriteEntry(ex.Message + " -ST- " + ex.StackTrace, EventLogEntryType.Error);
     }
 }