Beispiel #1
0
        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();
            }
        }
Beispiel #2
0
        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;
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            payload        = e.Parameter as Payload;
            lightModel     = payload.lm;
            lightViewModel = payload.lvm;

            this.DataContext = lightModel;
        }
Beispiel #5
0
        public MainPage()
        {
            this.InitializeComponent();
            lightsList = new LightViewModel();

            var UISyncContext = TaskScheduler.FromCurrentSynchronizationContext();

            Task.Run(async () => await apiManager.getLights(lightsList, UISyncContext));

            this.DataContext = lightsList;
        }
Beispiel #6
0
        public MainPage()
        {
            this.InitializeComponent();
            lightsList = new LightViewModel();

            var UISyncContext = TaskScheduler.FromCurrentSynchronizationContext();

            Task.Run(async() => await apiManager.getLights(lightsList, UISyncContext));

            this.DataContext = lightsList;
        }