private async void LoadPlan(string filePath, PlanType fileFormat) { IPlanManager reader = planManagerFactory.Create(fileFormat); PlanImportData plan = null; var tokenSource = new CancellationTokenSource(); var progress = new Progress <double>(); ViewManager.ShowProgress("$Planner.Importing.WaitTitle", "$Planner.Importing.WaitText", tokenSource, progress); try { plan = await Task.Run(() => reader.Read(filePath, tokenSource.Token, progress)); } catch (Exception ex) { tokenSource.Cancel(); recentPlansManager.RemoveFromRecentList(new RecentPlan(filePath, fileFormat)); Log.Error($"Unable to import observation plan: {ex}"); ViewManager.ShowMessageBox("$Error", $"{Text.Get("Planner.Importing.Error")}: {ex.Message}"); } if (!tokenSource.IsCancellationRequested) { tokenSource.Cancel(); if (plan?.Objects.Any() == true) { CreateNewPlan(plan); recentPlansManager.AddToRecentList(new RecentPlan(filePath, fileFormat)); } else if (ViewManager.ShowMessageBox("$Warning", Text.Get("Planner.Importing.NoCelestialObjectImported"), System.Windows.MessageBoxButton.YesNo) == System.Windows.MessageBoxResult.Yes) { CreateNewPlan(null); } } }