Example #1
0
        public async void DoWeather()
        {
            WeatherMethods Wm = new WeatherMethods();
            var            b  = await Wm.GetWeather(chosenLocation.ToString());

            string c     = b.ToString();
            string expl2 = ("It is " + c.ToString() + "°C");

            xTemperature.Text = expl2.ToString();
        }
Example #2
0
        public async void myPickerSelectedIndexChanged(object sender, EventArgs e)
        {
            //Method call every time when picker selection changed.
            var selectedValue = Pick.Items[Pick.SelectedIndex];

            chosenLocation = selectedValue;
            if (Pick.SelectedIndex == 0)
            {
            }
            else
            {
                Stopwatch stopWatch = new Stopwatch();
                stopWatch.Start();
                // Thread.Sleep(10000);

                //new thread to get weather

                Time     Tim = new Time();
                DateTime a   = await Tim.GetTime(chosenLocation.ToString());

                string y = a.ToString();
                y.ToString();
                string expl = ("It is " + y.ToString() + " in local time");

                xTime.Text = expl.ToString();

                WeatherMethods Wm = new WeatherMethods();
                var            b  = await Wm.GetWeather(chosenLocation.ToString());

                string c     = b.ToString();
                string expl2 = ("It is " + c.ToString() + "°C");
                xTemperature.Text = expl2.ToString();



                stopWatch.Stop();
                // Get the elapsed time as a TimeSpan value.
                TimeSpan ts = stopWatch.Elapsed;

                // Format and display the TimeSpan value.
                string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                   ts.Hours, ts.Minutes, ts.Seconds,
                                                   ts.Milliseconds / 10);
                string h = ("On One Thread it took : " + elapsedTime);
                xOneThread.Text = h.ToString();
            }
        }
Example #3
0
        //private async Task GetLocAsync(object sender, EventArgs e)
        //{
        //    Location Loc = new Location();
        //    string a = await Loc.GetLocationAsync();
        //    string y = a.ToString();

        //    xLocation.Text = y.ToString();
        //}

        private async void GetLocAsync(object sender, EventArgs e)
        {
            try
            {
                Location Loc = new Location();
                string   a   = await Loc.GetLocationAsync();

                string y = a.ToString();

                xLocation.Text = y.ToString();
                //Fix
                WeatherMethods Wm = new WeatherMethods();
                var            b  = await Wm.GetWeather(a.ToString());

                string c = b.ToString();
                xTemperature.Text = c.ToString();
            }
            catch (Exception GetLocAsyncEX)
            {
                await DisplayAlert("Error", GetLocAsyncEX.ToString(), "ok");

                throw;
            }
        }