private void dataGrid1_SelectionChanged(object sender, SelectionChangedEventArgs e) { var fileName = GetSelectedFileName(); if (fileName == null) { this.ClearEditor(); diffLines = new string[0]; return; } Action act = () => { service.NoRefresh = true; try { //var ret = tracker.DiffFile(fileName); //ret = ret.Replace("\r", "").Replace("\n", "\r\n"); //var tmpFileName = Path.ChangeExtension(Path.GetTempFileName(), ".diff"); //File.WriteAllText(tmpFileName, ret); var tmpFileName = tracker.Diff(fileName); if (!string.IsNullOrWhiteSpace(tmpFileName) && File.Exists(tmpFileName)) { if (new FileInfo(tmpFileName).Length > 2 * 1024 * 1024) { this.DiffEditor.Text = "File is too big to display: " + fileName; } else { diffLines = File.ReadAllLines(tmpFileName); this.ShowFile(tmpFileName); } } } catch (Exception ex) { //ShowStatusMessage(ex.Message); this.DiffEditor.Text = ex.Message; } service.NoRefresh = false; }; this.Dispatcher.BeginInvoke(act, DispatcherPriority.ApplicationIdle); }