public async Task getLights(LightViewModel lightViewModel, TaskScheduler context) { lvm = lightViewModel; try { var client = new HttpClient(); var response = await client.GetAsync(baseUrl); if (!response.IsSuccessStatusCode) { await new MessageDialog("Failed request").ShowAsync(); return; } string json = await response.Content.ReadAsStringAsync(); await Task.Run(() => { }).ContinueWith(a => { parseJson(json); }, context); } catch (OperationCanceledException) { await new MessageDialog("Operation time out").ShowAsync(); } }
public async Task getLights(LightViewModel lightViewModel, TaskScheduler context) { lvm = lightViewModel; try { var client = new HttpClient(); var response = await client.GetAsync(baseUrl); if (!response.IsSuccessStatusCode) { await new MessageDialog("Failed request").ShowAsync(); return; } string json = await response.Content.ReadAsStringAsync(); await Task.Run(()=> { }).ContinueWith(a => { parseJson(json); },context); } catch (OperationCanceledException) { await new MessageDialog("Operation time out").ShowAsync(); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { payload = e.Parameter as Payload; lightModel = payload.lm; lightViewModel = payload.lvm; this.DataContext = lightModel; }
public MainPage() { this.InitializeComponent(); lightsList = new LightViewModel(); var UISyncContext = TaskScheduler.FromCurrentSynchronizationContext(); Task.Run(async () => await apiManager.getLights(lightsList, UISyncContext)); this.DataContext = lightsList; }
public MainPage() { this.InitializeComponent(); lightsList = new LightViewModel(); var UISyncContext = TaskScheduler.FromCurrentSynchronizationContext(); Task.Run(async() => await apiManager.getLights(lightsList, UISyncContext)); this.DataContext = lightsList; }