Beispiel #1
0
 private void GetLocations(string query)
 {
     locations = WeatherProvider.GetLocations(query, Thread.CurrentThread.CurrentCulture);
     if (locations != null && locations.Count > 0)
     {
         foreach (var location in locations)
         {
             SearchResultBox.Dispatcher.Invoke((Action) delegate {
                 SearchResultBox.Items.Add(location);
             });
         }
     }
     else
     {
         SearchPopup.Dispatcher.Invoke((Action) delegate {
             SearchPopup.IsOpen = false;
         });
     }
 }
Beispiel #2
0
        private void Refresh()
        {
            ThreadStart threadStarter = () => {
                try {
                    var wr = WeatherProvider.GetWeatherReport(
                        Thread.CurrentThread.CurrentCulture,
                        package.CurrentWeather.Location,
                        package.WeatherOptions.TempScale
                        );
                    if (wr != null)
                    {
                        package.CurrentWeather = wr;
                        Dispatcher.BeginInvoke((Action)UpdateUI);
                    }
                }
                catch /* Eat */ { }
            };
            var thread = new Thread(threadStarter);

            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
        }