Esempio n. 1
0
        /// <summary>
        /// Cancel the download background worker.
        /// If the background worker is doing any work,
        /// this will cancel the download process.
        /// </summary>
        private void CancelDownload()
        {
            if (_adcpConn != null)
            {
                // Cancel the download process in the serial port
                _adcpConn.CancelDownload();
            }

            //try
            //{
            //    // Delete the file that was currently downloading
            //    if (File.Exists(DownloadDirectory + "\\" + DownloadFileName))
            //    {
            //        File.Delete(DownloadDirectory + "\\" + DownloadFileName);
            //    }
            //}
            //catch (Exception e)
            //{
            //    log.Error(string.Format("Could not access the file: {0} to delete.", DownloadFileName), e);
            //}

            // Wake up the bgworker if its asleep
            // so it can stop
            _downloadComplete  = true;
            _cancelDownload    = true;
            _isDownloadingData = false;
            this.NotifyOfPropertyChange(() => this.CanDownloadData);
            this.NotifyOfPropertyChange(() => this.CanCancelDownload);
            this.NotifyOfPropertyChange(() => this.CanPopulateDownloadList);
            this.NotifyOfPropertyChange(() => this.CanFormatSdCard);

            try
            {
                _eventWaitDownload.Set();
            }
            catch (Exception e)
            {
                log.Warn("Error stopping the download process.", e);
            }
        }