/// <summary>Called when building the line index completes (success or failure)</summary> private void BuildLineIndexComplete(BLIData d, RangeI range, List <RangeI> line_index, Exception error, Action on_success) { // This method runs in the main thread, so if the build issue is the same at // the start of this method it can't be changed until after this function returns. if (BuildCancelled(d.build_issue)) { return; } ReloadInProgress = false; UpdateStatusProgress(1, 1); // If an error occurred if (error != null) { if (error is OperationCanceledException) { } else if (error is FileNotFoundException) { SetStaticStatusMessage($"Error reading {Path.GetFileName(d.file.Name)}", Color.White, Color.DarkRed); } else { Log.Write(ELogLevel.Error, error, "Exception ended BuildLineIndex() call"); BuildLineIndexTerminatedWithError(error); } } // Otherwise, merge the results into the main cache else { // Merge the line index results int row_delta = MergeLineIndex(range, line_index, d.file_buffer_size, d.filepos, d.fileend, d.reload); // Ensure the grid is updated UpdateUI(row_delta); if (on_success != null) { on_success(); } // On completion, check if the file has changed again and rerun if it has Watch.CheckForChangedFiles(); // Trigger a collect to free up memory, this also has the // side effect of triggering a signing test of the exe because // that test is done in a destructor GC.Collect(); } }