示例#1
0
        public void GetTweetsAsync(Action <IEnumerable <Tweet> > success, Action <Exception> error)
        {
            _success = success;
            _error   = error;

            MvxAsyncDispatcher.BeginAsync(DoAsyncSearch);
        }
示例#2
0
 private void OnRequestFinished(MvxFileDownloadRequest request)
 {
     lock (this)
     {
         _currentRequests.Remove(request);
         if (_queuedRequests.Any())
         {
             MvxAsyncDispatcher.BeginAsync(StartNextQueuedItem);
         }
     }
 }
示例#3
0
 public void RequestAsyncSave(List <string> toSave)
 {
     lock (this)
     {
         var wasNull = _toSave == null;
         _toSave = toSave;
         if (wasNull)
         {
             MvxAsyncDispatcher.BeginAsync(DoSave);
         }
     }
 }
示例#4
0
        private void DoRefreshTail()
        {
            if (IsRefreshingTail)
            {
                return;
            }

            IsRefreshingTail = true;
            MvxAsyncDispatcher.BeginAsync(() =>
            {
                MvxAsyncDispatcher.Sleep(3000);
                this.InvokeOnMainThread(() =>
                {
                    AddEmailsTail(1 + Random.Next(5));
                    IsRefreshingTail = false;
                });
            });
        }
        private void DoRefreshHead()
        {
            if (IsRefreshingHead)
            {
                return;
            }

            IsRefreshingHead = true;
            MvxAsyncDispatcher.BeginAsync(() =>
            {
                Sleeper.Sleep(TimeSpan.FromSeconds(2.0));
                this.InvokeOnMainThread(() =>
                {
                    AddEmailsHead(1 + Random.Next(5));
                    IsRefreshingHead = false;
                });
            });
        }
示例#6
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);
                }
            }
        }
示例#7
0
 public static void StartAsyncSearch(string searchText, Action <IEnumerable <Tweet> > success, Action <Exception> error)
 {
     MvxAsyncDispatcher.BeginAsync(() => DoAsyncSearch(searchText, success, error));
 }
 public void BeginAsyncLoad()
 {
     IsLoading = true;
     MvxAsyncDispatcher.BeginAsync(Load);
 }
示例#9
0
 public void RequestImage(string url, Action <T> success, Action <Exception> error)
 {
     MvxAsyncDispatcher.BeginAsync(() => DoRequestImage(url, success, error));
 }