public bool openRsEx(bool showWindowCancel, bool raiseProgressEvent, bool showModal, string sqlstmt, out DbDataReader ors, string function, string module, string title) { bool cancelDialogShowed = false; fCancelQuery f = null; ors = null; try { // create a command to execute the query cOpenRsCommand cmd = new cOpenRsCommand(); cmd.getExecuteCommand(this, sqlstmt); // execute in asynchronous mode cmd.execute(); int seconds = 0; bool queryCanceled = false; // wait until the query finish while (!cmd.done) { // cancel dialog if (showWindowCancel && seconds > 200) { // show the cancel dialog if (!cancelDialogShowed) { f = new fCancelQuery(); if (m_openRsExDescript != "") { f.descript = "Getting data for: " + m_openRsExDescript; } f.Show(); cancelDialogShowed = true; } } // events if (raiseProgressEvent) { if (openRsProgress != null) { openRsProgress(); } } Application.DoEvents(); if (cancelDialogShowed) { if (f.cancel) { queryCanceled = true; break; } } System.Threading.Thread.Sleep(100); seconds += 100; } // hide cancel dialog if (showWindowCancel && cancelDialogShowed) { f.Hide(); } if (queryCanceled) { pReconnect(); return false; } else { ors = cmd.ors; return cmd.success; } } catch (Exception ex) { cError.mngError(ex, "openRsEx", c_module, ""); return false; } finally { f = null; } }