Exemplo n.º 1
0
        private void ListPainelRefresh(object obj)
        {
            ModelPainel _modelPainel = new ModelPainel();

            this.ListPainel_IsRefreshing = true;

            try
            {
                _tokensource = new CancellationTokenSource();
                Task.Run(async() =>
                {
                    ServiceResult <List <PainelDto> > result = await _modelPainel.ListPainelAsync(
                        _tokensource.Token
                        );

                    if (!_tokensource.IsCancellationRequested)
                    {
                        UpdateToken(result.RefreshToken);
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            if (!String.IsNullOrWhiteSpace(result.MessageError))
                            {
                                _messageService.ShowAlertAsync(result.MessageError);
                            }

                            App.ListPainelSource         = result.Data;
                            this.ListPainel_Source       = App.ListPainelSource;
                            this.ListPainel_IsRefreshing = false;

                            Loop(_refreshTime);
                        });
                    }
                }, _tokensource.Token);
            }
            catch (Exception ex)
            {
                _messageService.ShowAlertAsync(ex.Message, AppResources.Erro);
                this._navigationService.NavigateToLogin();
            }
        }
        private void ListPainelTopRefresh()
        {
            ModelPainel _modelPainel = new ModelPainel();

            _viewComandos.ExibirLoad();

            try
            {
                Task.Run(async() =>
                {
                    try
                    {
                        //ServiceResult<List<PainelDto>> resultPainel = await _modelPainel.ListPainelAsync();

                        Device.BeginInvokeOnMainThread(() =>
                        {
                            try
                            {
                                this.ListPainelTop_Source = _painel;
                                _viewComandos.EscondeLoad();
                            }
                            catch (Exception)
                            {
                            }
                        });
                    }
                    catch (Exception)
                    {
                    }
                }, _tokensource.Token);
            }
            catch (Exception)
            {
                _viewComandos.EscondeLoad();
            }
            finally
            {
            }
        }