public static async void get(string uri, Action <string> action) { WebClient wc = new WebClient(); string result = await BackGroundThread.DownloadAsync(wc, uri); action(result); }
private void RetrieveData() { BackGroundThread.get(BackGroundThread.urlWeather, (json) => { Console.WriteLine("Json string"); Console.WriteLine(json); BackGroundThread.str_requestedData = json; Console.WriteLine("Requested data"); Console.WriteLine(BackGroundThread.str_requestedData); String temp = BackGroundThread.str_requestedData; temp = temp.Replace("[", ""); temp = temp.Replace("]", ""); Console.WriteLine("Deserializing json"); Console.WriteLine(temp); //deserialize json and set label values BackGroundThread.requestedData = JsonConvert.DeserializeObject <RequestedData>(temp); UpdateUI(); }); }