Exemplo n.º 1
0
 private void OnRequestFinished(MvxFileDownloadRequest request)
 {
     lock (this)
     {
         _currentRequests.Remove(request);
         if (_queuedRequests.Any())
         {
             MvxAsyncDispatcher.BeginAsync(StartNextQueuedItem);
         }
     }
 }
 private void OnRequestFinished(MvxFileDownloadRequest request)
 {
     RunSyncOrAsyncWithLock(() =>
     {
         _currentRequests.Remove(request);
         if (_queuedRequests.Any())
         {
             StartNextQueuedItem();
         }
     });
 }
 private void OnRequestFinished(MvxFileDownloadRequest request)
 {
     RunSyncOrAsyncWithLock(() =>
         {
             _currentRequests.Remove(request);
             if (_queuedRequests.Any())
             {
                 StartNextQueuedItem();
             }
         });
 }
Exemplo n.º 4
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);
                }
            }
        }
        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.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 MvxFileDownloadRequest(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();
                }
            });
        }