private async void OpenLogFile(string filePath) { if (!File.Exists(filePath)) { return; } DisplayBuild(null); this.logFilePath = filePath; SettingsService.AddRecentLogFile(filePath); UpdateRecentItemsMenu(); Title = filePath + " - " + DefaultTitle; var progress = new BuildProgress(); progress.Progress.Updated += update => { Dispatcher.InvokeAsync(() => { progress.Value = update.Ratio; }, DispatcherPriority.Background); }; progress.ProgressText = "Opening " + filePath + "..."; SetContent(progress); bool shouldAnalyze = true; var stopwatch = Stopwatch.StartNew(); Build build = await System.Threading.Tasks.Task.Run(() => { try { return(Serialization.Read(filePath, progress.Progress)); } catch (Exception ex) { ex = ExceptionHandler.Unwrap(ex); shouldAnalyze = false; return(GetErrorBuild(filePath, ex.ToString())); } }); if (build == null) { build = GetErrorBuild(filePath, ""); shouldAnalyze = false; } if (shouldAnalyze) { progress.ProgressText = "Analyzing " + filePath + "..."; await System.Threading.Tasks.Task.Run(() => BuildAnalyzer.AnalyzeBuild(build)); } progress.ProgressText = "Rendering tree..."; await Dispatcher.InvokeAsync(() => { }, DispatcherPriority.Loaded); // let the progress message be rendered before we block the UI again DisplayBuild(build); var elapsed = stopwatch.Elapsed; if (currentBuild != null) { currentBuild.UpdateBreadcrumb($"Load time: {elapsed}"); } }