protected virtual void DownloadDataCompleteEvent(DownloadCompleteData e) { EventHandler<DownloadCompleteData> handler = downloadDatacomplete; if (handler != null) { handler(this, e); } }
async void DownloadDataAsync(String url) { HttpClient client = new HttpClient(); Task<string> getStringTask = client.GetStringAsync(url); string urlContents = await getStringTask; DownloadCompleteData data_to_send = new DownloadCompleteData(); data_to_send.data = urlContents; DownloadDataCompleteEvent(data_to_send); }
void data_arrived(object sender, DownloadCompleteData e) { String data = e.data; JArray obj = JArray.Parse(data); for (int i = 0; i < obj.Count; i++) { JObject row = JObject.Parse(obj[i].ToString()); var item = new DataList(); item.country = row["country"].ToString(); item.code = row["code"].ToString(); list.Items.Add(item); } }