示例#1
0
        /// <summary>
        /// Do it!
        /// </summary>
        /// <param name="fileDownloadInfo">Info of the file to download</param>
        private void DoWork(FileDownloadInfo fileDownloadInfo)
        {
            Exception resultException = null;

            try
            {
                if (fileDownloadInfo.LocalFile.Exists && !fileDownloadInfo.OverwriteExistingFile)
                {
                    Logger.Warn("File {0} already exists. Skipping.", fileDownloadInfo.LocalFile);
                    resultException = new FileDownloadExistsException();
                }
                else
                {
                    try
                    {
                        this.Download(fileDownloadInfo);
                    }
                    catch (FileDownloadRetryException)
                    {
                        lock (downloadThreadPoolLockObject)
                        {
                            downloadThreadPool.QueueWorkItem(this.DoWork, fileDownloadInfo, fileDownloadInfo.Priority);
                        }

                        return;
                    }
                    catch (Exception e)
                    {
                        resultException = e;
                    }
                }
            } 
            catch (Exception e)
            {
                resultException = e;
            }

            var eventArgs = new FileDownloadProgressEventArgs(fileDownloadInfo, resultException);
            DownloadProgressNotification(this, eventArgs);
        }
示例#2
0
 private static void DownloadMissingArtworkProgress(FileDownloader s, FileDownloadProgressEventArgs e)
 {
     Logger.Trace("Queue length: {0} | Completed download: {1}", s.ActiveWorkItems + s.WaitingWorkItems, e.FileDownloadInfo.Url);
 }