コード例 #1
0
        /// <summary>
        /// will exit if a download has started
        /// or calls the complete if there is no download next
        /// or sets the next download to start and call StartNextDownload()
        /// finally each protocol has a different implementation
        /// </summary>
        protected void ProtocolStartDownloading()
        {
            BeforeStartDownloading();
            //process not started || download pending
            if (DownloadsController.CurrentDownload?.DownloadState == DownloadState.Started || ProtocolDownloaderManager.Shutdown)
            {
                return;
            }

            //the waiting list has been completely served
            if (DownloadsController.NextDownload == null)
            {
                DownloadsController.ClearDownloads();
                OnDownloadsControllerCompleted();
                return;
            }

            //else, we have our next download to start
            DownloadsController.CurrentDownload = DownloadsController.NextDownload;

            DownloadsController.CurrentDownload.ChangeState(DownloadState.Started);
            //the second event
            OnProcessStarted();
            //depending on the url, the correct protocol will be assigned for the task
            ((Downloader)ProtocolDownloaderManager.GetInstance(DownloadsController.CurrentDownload.RemoteFileInfo.Url)).StartNextDownload();
        }
コード例 #2
0
        public void ProtocolAbortCurrentDownload(bool shutdown)
        {
            ProtocolDownloaderManager.Shutdown = shutdown;
            string file = Path.Combine(DownloadsController.CurrentDownload.Destination.FullPath, DownloadsController.CurrentDownload.RemoteFileInfo.FileFullName);

            //depending on the url, the correct protocol will be assigned for the task
            ((Downloader)ProtocolDownloaderManager.GetInstance(DownloadsController.CurrentDownload.RemoteFileInfo.Url)).AbortCurrentDownload();

            //async calls might need a few seconds to marshal
            Thread.Sleep(2000);
        }