private void OnRequestFinished(MvxFastFileDownloadRequest request) { RunSyncOrAsyncWithLock(() => { _currentRequests.Remove(request); if (_queuedRequests.Any()) { StartNextQueuedItem(); } }); }
public void RequestDownload(string url, string downloadPath, Action success, Action<Exception> error) { var request = new MvxFastFileDownloadRequest(url, downloadPath); request.DownloadComplete += (sender, args) => { OnRequestFinished(request); success(); }; request.DownloadFailed += (sender, args) => { OnRequestFinished(request); error(args.Value); }; RunSyncOrAsyncWithLock( () => { _queuedRequests.Enqueue(request); if (_currentRequests.Count < _maxConcurrentDownloads) { StartNextQueuedItem(); } }); }
public void RequestDownload(string url, string downloadPath, Action success, Action <Exception> error) { var request = new MvxFastFileDownloadRequest(url, downloadPath); request.DownloadComplete += (sender, args) => { OnRequestFinished(request); success(); }; request.DownloadFailed += (sender, args) => { OnRequestFinished(request); error(args.Value); }; RunSyncOrAsyncWithLock(() => { _queuedRequests.Enqueue(request); if (_currentRequests.Count < _maxConcurrentDownloads) { StartNextQueuedItem(); } }); }