Exemplo n.º 1
0
        public async Task GetUpdate()
        {
            if (_isUpdating)
            {
                return;
            }

            try
            {
                _isUpdating = true;

                UpdatesRequest request = new UpdatesRequest();
                request.last_activity_date = LastActivity;
                UpdatesResponse response = await request.GetUpdate();

                if (response.Matches != null && response.Matches.Length > 0)
                {
                    _matches.Update(response.Matches);
                }

                LastActivity = DateTime.Parse(response.LastActivityDate);
            }
            catch (HttpRequestException e)
            {
                if (e.Message.Contains("Unauthorized"))
                {
                    (Application.Current as IApp).Logout();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception during update: " + ex.Message);
            }
            finally
            {
                _isUpdating = false;
            }
        }