private async void UpdateUI(ThreadPoolTimer timer) { // Perform the data computations string estimateTextBlockText = await Task <string> .Run(() => MainDataStore.GetArrivalEstimates(currOrigin, currDest)); Tuple <List <string>, string, string> scheduleResults = await DataStore.Scheduler.CreateSchedule(currOrigin, currDest); // Update the UI bool isRunning = false; await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { isRunning = UpdateTextBoxes(scheduleResults.Item1, scheduleResults.Item2, scheduleResults.Item3, estimateTextBlockText); }); if (!isRunning) { scheduleResults = null; return; } // Grab more data Dictionary <string, Tuple <string, string, List <List <Point> > > > routeMap2; routeMap2 = await MainDataStore.GetRoutes(currOrigin, currDest); await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { Dictionary <string, Tuple <string, string, List <LocationCollection> > > routeMap = ConvertToRouteMap(routeMap2); // If there are no routes, hide map and color code, replace with message that there are no routes currently running if (routeMap.Keys.Count == 0) { this.shuttleMap.Visibility = Visibility.Collapsed; this.ColorCodePanel.Visibility = Visibility.Collapsed; this.notRunningTextBlock.Visibility = Visibility.Visible; this.notRunningTextBlock2.Visibility = Visibility.Visible; } else { // Update the cache of route IDs and their colors commonRouteIDsColors.Clear(); // race condition here with shuttles, but it will be resolved the period after if there's a failure foreach (var key in routeMap.Keys) { commonRouteIDsColors[key] = routeMap[key].Item2; } } // clean up routeMap.Clear(); routeMap = null; }); // clean up routeMap2 = null; scheduleResults.Item1.Clear(); scheduleResults = null; }
private async Task <Dictionary <string, Tuple <string, string, List <LocationCollection> > > > PopulateUI() { // Grab arrival estimates and the schedule string estimateTextBlockText = await Task <string> .Run(() => MainDataStore.GetArrivalEstimates(currOrigin, currDest)); Tuple <List <string>, string, string> scheduleResults = await DataStore.Scheduler.CreateSchedule(currOrigin, currDest); // Update the UI bool isRunning = UpdateTextBoxes(scheduleResults.Item1, scheduleResults.Item2, scheduleResults.Item3, estimateTextBlockText); if (!isRunning) { return(null); } // Create a route map for updating the color code and the routes Dictionary <string, Tuple <string, string, List <List <Point> > > > routeMap2; routeMap2 = await MainDataStore.GetRoutes(currOrigin, currDest); Dictionary <string, Tuple <string, string, List <LocationCollection> > > routeMap = ConvertToRouteMap(routeMap2); // update the color code UI // if there are no routes, hide map and color code, replace with message that there are no routes currently running if (routeMap.Keys.Count == 0) { this.shuttleMap.Visibility = Visibility.Collapsed; this.ColorCodePanel.Visibility = Visibility.Collapsed; this.notRunningTextBlock.Visibility = Visibility.Visible; this.notRunningTextBlock2.Visibility = Visibility.Visible; routeMap = null; // return null if there's nothing to show } // clean up routeMap2 = null; scheduleResults = null; return(routeMap); }