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

            this.DataContext = lightModel;
        }
예제 #4
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            payload        = e.Parameter as Payload;
            lightModel     = payload.lm;
            lightViewModel = payload.lvm;

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

            var UISyncContext = TaskScheduler.FromCurrentSynchronizationContext();

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

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

            var UISyncContext = TaskScheduler.FromCurrentSynchronizationContext();

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

            this.DataContext = lightsList;
        }