private void updateDownloading() { if (!_isUpdateDowningIfChanged || !_needDowning) { return; } _needDowning = false; while (DownloadingLimitManager.Instance.IsDownloadingLess()) { Console.WriteLine("{0} - {1}", DownloadingLimitManager.Instance.DownloadingNum, DownloadingLimitManager.Instance.DownloadingSup); lock (_downloads) { var down = _downloads.FirstOrDefault(_ => _.DownloadStatus == DownloadStatus.Waiting); if (down != null) { down.Start(); } else { break; } } } while (DownloadingLimitManager.Instance.IsDownloadingMore()) { Console.WriteLine("{0} - {1}", DownloadingLimitManager.Instance.DownloadingNum, DownloadingLimitManager.Instance.DownloadingSup); lock (_downloads) { var down = _downloads.LastOrDefault(_ => DownloadStatusManager.IsDownloading(_.DownloadStatus) && !_.IsPrior); if (down != null) { down.Waiting(); } else { break; } } } }
public void Start() { if (DownloadStatus == DownloadStatus.Completed) { return; } if (DownloadStatusManager.IsDownloading(DownloadStatus)) { return; } if (IsPrior || DownloadingLimitManager.Instance.IsDownloadingLess()) { removeInvalidDownloadingNum(); _downloading = true; DownloadingLimitManager.Instance.DownloadingNum++; updateThread(); _downloader.Start(); } else { Waiting(); } }