async void FindReplacementsAsync() { Replacements.Clear(); replacementsModel.SetReplaced(DisplayedCourses.ElementAt(SelectedCourseIndex).Model); List <ReplacementModel> result = null; result = await Task.Run(() => { try { return(replacementsModel.GetReplacementsFromData()); } catch (DataServiceException e) { Debug.WriteLine(e.Message); ShowAlert(); } return(result); }); if (result != null) { foreach (ReplacementModel rm in result) { Replacements.Add(new ReplacementViewModel(rm)); } } }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { lock (this) { // close all connections on dispose CloseConnections(); // empty dictionaries Connections.Clear(); Replacements.Clear(); } }