public async Task <IEnumerable <Item> > GetItemsAsync(bool forceRefresh = false) { var restItems = new List <Item>(); server = props.GetPropertyValue("Server"); GetRestURL(server); if (props.GetPropertyValue("DatabaseOnline").Equals("Online")) { try { using (var client = new HttpClient { Timeout = TimeSpan.FromMilliseconds(30000) }) { client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); string RestUrl = this.RestUrlHead; var response = await client.GetAsync(new Uri(string.Format(RestUrl, string.Empty))); HttpStatusCode statusCode = response.StatusCode; var content = await response.Content.ReadAsStringAsync(); props.SetPropertyValue("DatabaseOnline", "Online"); await fileEngine.WriteTextAsync("PackageData.json", content); restItems = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Item> >(content); } } catch (TaskCanceledException tcex) { props.SetPropertyValue("DatabaseOnline", "Offline"); restItems = await GetOfflineData(restItems); Console.WriteLine("taskcanceled: " + tcex.Message); } catch (Exception ex) { props.SetPropertyValue("DatabaseOnline", "Offline"); restItems = await GetOfflineData(restItems); Console.WriteLine("taskexception: " + ex.Message); } } else { props.SetPropertyValue("DatabaseOnline", "Offline"); restItems = await GetOfflineData(restItems); } return(restItems); }