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