Example #1
0
 void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (copy != null)
     {
         copy.Stop();
         copy.Dispose();
     }
 }
Example #2
0
 /// <summary>
 /// Executes when a Stop command is sent to the service by the Service Control Manager.
 /// NOTE: the method is NOT triggered when the operating system shuts down, instead
 /// the OnShutdown() method is used!
 /// </summary>
 protected override void OnStop()
 {
     Log.Warn("{0} service stop requested...", ServiceName);
     if (_transferState != TxState.Stopped)
     {
         _transferState = TxState.DoNothing;
         // RoboCommand.Stop() is calling Process.Kill() (immediately forcing a termination
         // of the process, returning asynchronously), followed by Process.Dispose()
         // (releasing all resources used by the component). Would be nice if RoboSharp
         // implemented a method to check if the process has actually terminated, but
         // this is probably something we have to do ourselves.
         // TODO: this has probably improved with recent versions of RoboSharp, check it!
         try {
             _roboCommand.Stop();
         }
         catch (Exception ex) {
             Log.Error("Error terminating the RoboCopy process: {0}", ex.Message);
         }
         _status.TransferInProgress = true;
         Log.Info("Not all files were transferred - will resume upon next start");
         Log.Debug("CurrentTransferSrc: " + _status.CurrentTransferSrc);
         // should we delete an incompletely transferred file on the target?
         SendTransferInterruptedMail();
     }
     // set the shutdown status to clean:
     _status.CleanShutdown = true;
     Log.Info("-----------------------");
     Log.Info("{0} service stopped", ServiceName);
     Log.Info("-----------------------");
 }
Example #3
0
        private void CopyForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            _RoboCommand.OnCopyProgressChanged -= _RoboCommand_OnCopyProgressChanged;
            _RoboCommand.OnFileProcessed       -= _RoboCommand_OnFileProcessed;
            _RoboCommand.OnCommandCompleted    -= _RoboCommand_OnCommandCompleted;

            _RoboCommand.Stop();

            _RoboCommand.Dispose();
        }