public async Task SaveTimers() { ArrayClassForJSON dd = new ArrayClassForJSON(); dd.timers = tims; string jsonString = JsonConvert.SerializeObject(dd); HttpClient client = new HttpClient(); System.Uri uri = new Uri("http://" + Common.Instance.LocsiHostname + "/settimers"); HttpContent content = new StringContent(jsonString); HttpResponseMessage resp = await client.PostAsync(uri, content); }
public async Task GetTimers() { try { HttpClient client = new HttpClient(); System.Uri uri = new System.Uri("http://" + Common.Instance.LocsiHostname + "/gettimers"); HttpResponseMessage response = await client.GetAsync(uri); if (response.IsSuccessStatusCode) { var content = await response.Content.ReadAsStringAsync(); ArrayClassForJSON dd = JsonConvert.DeserializeObject <ArrayClassForJSON>(content); tims = dd.timers; } } catch { System.Threading.Thread.Sleep(1000); await GetTimers(); } }