private async Task InitializeWeather(Reservation currentTrip) { WeatherForecast weather = null; if (currentTrip != null) { var flightInfo = currentTrip.DepartureFlight.FlightInfo; var locationId = flightInfo.Flight.Destination.LocationId; var departure = flightInfo.Departure ?? DateTime.Now; weather = await _data.GetWeatherForecastByIdAsync(locationId, departure); ApplicationData.Current.LocalSettings.Values["locationId"] = locationId; ApplicationData.Current.LocalSettings.Values["locationName"] = flightInfo.Flight.Source.City; ApplicationData.Current.LocalSettings.Values["departure"] = string.Format("{0:yyyy-MM-dd}", departure); } Weather = weather; var weatherUpdateTask = BackgroundTaskHelper.FindRegisteredTask(Constants.WeatherTaskName); if (weatherUpdateTask != null) { weatherUpdateTask.Completed += WeatherUpdateTaskOnCompleted; } }
private void UninitializeWeather() { var weatherUpdateTask = BackgroundTaskHelper.FindRegisteredTask(Constants.WeatherTaskName); if (weatherUpdateTask != null) { weatherUpdateTask.Completed -= WeatherUpdateTaskOnCompleted; } }