コード例 #1
0
 private void OnRequestFinished(MvxFileDownloadRequest request)
 {
     lock (this)
     {
         _currentRequests.Remove(request);
         if (_queuedRequests.Any())
         {
             MvxAsyncDispatcher.BeginAsync(StartNextQueuedItem);
         }
     }
 }
コード例 #2
0
        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);
                }
            }
        }