public void fetchBytesOfFiles(string[] pathOfFiles) { try { parent_Grid.Dispatcher.Invoke(new Action(delegate { parent_Grid.BeginDataUpdate(); }), System.Windows.Threading.DispatcherPriority.DataBind); foreach (string filePath in pathOfFiles) { bool isDirectory = filePath.IsDirectory(); string fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(filePath); string fileType = (isDirectory) ? @"<Folder>" : System.IO.Path.GetExtension(filePath); long fileSizeInBytes = (isDirectory) ? GetDirectorySize(filePath) : GetFileSize(filePath); TreeListNode node = new TreeListNode() { Content = new RowItem(fileNameWithoutExtension, fileType, fileSizeInBytes, filePath) }; node.IsExpandButtonVisible = (isDirectory && HasFiles(filePath)) ? DefaultBoolean.True : DefaultBoolean.False; writeFileBytesOnTheRAM(node); parent_TreeListView.Dispatcher.Invoke(new Action(delegate { parent_TreeListView.Nodes.Add(node); }), System.Windows.Threading.DispatcherPriority.DataBind); if (node.IsExpandButtonVisible == DefaultBoolean.True) { InitOneFolder(node); } parent_TreeListView.Dispatcher.Invoke(new Action(delegate { parent_TreeListView.CollapseAllNodes(); }), System.Windows.Threading.DispatcherPriority.Render); } } catch (IOException io) { parent_Window.Dispatcher.Invoke(new Action(delegate { MsgBox.Show(io.Message, io.Source, parent_Window); }), System.Windows.Threading.DispatcherPriority.Render); } catch (Exception ex) { parent_Window.Dispatcher.Invoke(new Action(delegate { MsgBox.Show(ex.Message, ex.Source, parent_Window); }), System.Windows.Threading.DispatcherPriority.Render); } finally { parent_Grid.Dispatcher.Invoke(new Action(delegate { parent_Grid.EndDataUpdate(); }), System.Windows.Threading.DispatcherPriority.DataBind); } }
void UpdateItems() { StepLeftCustomSummaryInfo(); grid.BeginDataUpdate(); foreach (StockItem item in data) { item.UpdatePrice(rnd); if (Math.Sign(item.DeltaPrice) > 0) { positivePriceHistory[StockItem.HistoryLength - 1]++; } else { negativePriceHistory[StockItem.HistoryLength - 1]++; } } grid.EndDataUpdate(); }
/// <summary> /// Обновление данных в grid /// </summary> protected async void RefreshGridData() { var selected = GridControl.SelectedItems; var topGridRow = GridControl.View.TopRowIndex; if (GridControl.ItemsSource != null) { SaveCurrentLayout(); } GridControl.BeginDataUpdate(); GridControl.ItemsSource = await ExecAsync(GetData, CancellationToken.None); GridControl.EndDataUpdate(); RestoreLayout(); GridControl.View.Focus(); GridControl.SelectedItems = selected; GridControl.View.TopRowIndex = topGridRow; }