public static async Task <WeatherQueryModel> GetWeatherInfomationAsync() { Stream xmlstream; WeatherQueryModel weatherInfomation = new WeatherQueryModel(); void getstream() { xmlstream = GetWeatherInformationFromStream(CityInformation.余姚); if (xmlstream != null) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(WeatherQueryModel)); weatherInfomation = (WeatherQueryModel)xmlSerializer.Deserialize(xmlstream); } } await Task.Run(() => getstream()); return(weatherInfomation); }
private async void BaseControl_Loaded(object sender, RoutedEventArgs e) { WeatherInformation = await WeatherInformationService.GetWeatherInfomationAsync(); }