/// <summary> /// End table caching by writing out remaining records & opening file reader /// </summary> public void EndCaching() { if (!AllowCaching) { return; } if (CacheStartPosition < 0 || CacheWriter == null) { return; // caching active } if (RowsRemovedFromDataTable == 0) { if (CacheWriter != null) { CacheWriter.Close(); CacheWriter = null; } CacheStartPosition = -1; return; } if (RowRetrievalState == RowRetrievalState.Running || RowRetrievalState == RowRetrievalState.Paused) { CancelRowRetrieval(); // cancel if not complete } WriteRowsToCache(false); // write out remaining rows CacheWriter.Close(); CacheWriter = null; CacheReader = new StreamReader(CacheFile); CacheStartPosition = -1; //RowCount = CacheStartRowCount; // restore counts (todo: fix this: gives zero for export count with this code) //KeyCount = CacheStartKeyCount; RowRetrievalState = RowRetrievalState.Paused; if (DebugDetails) { ClientLog.Message("RowRetrievalState.Paused 3"); } if (QueryManager.MoleculeGrid != null) { QueryManager.MoleculeGrid.EndUpdate(); QueryManager.MoleculeGrid.Refresh(); Application.DoEvents(); } if (StatusBarManager != null) { // update status bar, may process an event that generates a request for more rows StatusBarManager.DisplayRetrievalProgressState(RowRetrievalState); StatusBarManager.DisplayFilterCounts(); // update count display } if (DebugCaching) { ClientLog.Message("EndCaching: " + DataTableMx.Rows.Count); } return; }