private void DoWork(object sender, DoWorkEventArgs e) { RefreshGridRequest refreshRequest; lock (_locker) { refreshRequest = queue.Count > 0 ? queue.Dequeue() : null; } if (worker.CancellationPending) { return; } if (refreshRequest == null || refreshRequest.SR == null) { return; } SrStoragePage page = owner as SrStoragePage; if (page == null) { return; } if (refreshRequest.Reset) { Program.Invoke(owner, page.dataGridViewVDIs.Rows.Clear); } Program.Invoke(owner, page.RefreshButtons); IEnumerable <VDIRow> currentVDIRows = Enumerable.Empty <VDIRow>(); Program.Invoke(owner, () => currentVDIRows = page.GetCurrentVDIRows()); VDIsData data = GetCurrentData(refreshRequest.SR, currentVDIRows); if (worker.CancellationPending) { return; } Program.Invoke(owner, () => ((SrStoragePage)owner).RefreshDataGridView(data)); }
private void RefreshDataGridView(VDIsData data) { dataGridViewVDIs.SuspendLayout(); try { ColumnVolume.Visible = data.ShowStorageLink; var showCbtColumn = !Helpers.FeatureForbidden(sr.Connection, Host.RestrictChangedBlockTracking); ColumnCBT.Visible = showCbtColumn; // Update existing rows foreach (var vdiRow in data.VdiRowsToUpdate) { vdiRow.RefreshRowDetails(showCbtColumn); } // Remove rows for deleted VDIs foreach (var vdiRow in data.VdiRowsToRemove) { dataGridViewVDIs.Rows.RemoveAt(vdiRow.Index); } // Add rows for new VDIs foreach (var vdi in data.VdisToAdd) { dataGridViewVDIs.Rows.Add(new VDIRow(vdi, showCbtColumn)); } } finally { if (dataGridViewVDIs.SortedColumn != null && dataGridViewVDIs.SortOrder != SortOrder.None) { dataGridViewVDIs.Sort(dataGridViewVDIs.SortedColumn, dataGridViewVDIs.SortOrder == SortOrder.Ascending ? ListSortDirection.Ascending : ListSortDirection.Descending); } dataGridViewVDIs.ResumeLayout(); } RefreshButtons(); }
private void RefreshDataGridView(VDIsData data) { dataGridViewVDIs.SuspendLayout(); try { storageLinkVolumeColumn.Visible = data.ShowStorageLink; // Update existing rows foreach (var vdiRow in data.VdiRowsToUpdate) { vdiRow.RefreshRowDetails(data.ShowStorageLink); } // Remove rows for deleted VDIs foreach (var vdiRow in data.VdiRowsToRemove) { dataGridViewVDIs.Rows.RemoveAt(vdiRow.Index); } // Add rows for new VDIs foreach (var vdi in data.VdisToAdd) { VDIRow newRow = new VDIRow(vdi, data.ShowStorageLink); dataGridViewVDIs.Rows.Add(newRow); } } finally { if (dataGridViewVDIs.SortedColumn != null && dataGridViewVDIs.SortOrder != SortOrder.None) { dataGridViewVDIs.Sort(dataGridViewVDIs.SortedColumn, dataGridViewVDIs.SortOrder == SortOrder.Ascending ? ListSortDirection.Ascending : ListSortDirection.Descending); } dataGridViewVDIs.ResumeLayout(); } RefreshButtons(); }
private void RefreshDataGridView(VDIsData data) { dataGridViewVDIs.SuspendLayout(); try { storageLinkVolumeColumn.Visible = data.ShowStorageLink; // Update existing rows foreach (var vdiRow in data.VdiRowsToUpdate) { vdiRow.RefreshRowDetails(data.ShowStorageLink); } // Remove rows for deleted VDIs foreach (var vdiRow in data.VdiRowsToRemove) { dataGridViewVDIs.Rows.RemoveAt(vdiRow.Index); } // Add rows for new VDIs foreach (var vdi in data.VdisToAdd) { VDIRow newRow = new VDIRow(vdi, data.ShowStorageLink); dataGridViewVDIs.Rows.Add(newRow); } } finally { if (dataGridViewVDIs.SortedColumn != null && dataGridViewVDIs.SortOrder != SortOrder.None) dataGridViewVDIs.Sort(dataGridViewVDIs.SortedColumn, dataGridViewVDIs.SortOrder == SortOrder.Ascending ? ListSortDirection.Ascending : ListSortDirection.Descending); dataGridViewVDIs.ResumeLayout(); } RefreshButtons(); }