public void MinimizeResults() { bool dispose = true; var dlg = new MinimizeResultsDlg(DocumentUIContainer); try { if (dlg.ShowDialog(this) == DialogResult.OK) { // If the MinimizeResultsDlg did work then cancel out of this dialog DialogResult = DialogResult.Cancel; } } catch { dispose = false; throw; } finally { // NOTE: We do a manual Dispose rather than "using", because something in the constructor // is occasionally throwing an exception. Unfortunately, that exception gets masked when // "using" calls Dispose during exception processing, and Dispose throws an exception. if (dispose) { int count = 0; while (!dlg.IsDisposed) { try { dlg.Dispose(); break; } catch { // After 10 tries, just throw the exception (usually only once is required) if (count++ > 10) { throw; } Thread.Sleep(50); // Give the dialog time to finish whatever caused this exception } } } } }
public BackgroundWorker(MinimizeResultsDlg dlg, ILongWaitBroker longWaitBroker) { _dlg = dlg; _longWaitBroker = longWaitBroker; }
public void MinimizeResults() { bool dispose = true; var dlg = new MinimizeResultsDlg(DocumentUIContainer); try { if (dlg.ShowDialog(this) == DialogResult.OK) { // If the MinimizeResultsDlg did work then cancel out of this dialog DialogResult = DialogResult.Cancel; } } catch { dispose = false; throw; } finally { // NOTE: We do a manual Dispose rather than "using", because something in the constructor // is occasionally throwing an exception. Unfortunately, that exception gets masked when // "using" calls Dispose during exception processing, and Dispose throws an exception. if (dispose) { int count = 0; while (!dlg.IsDisposed) { try { dlg.Dispose(); break; } catch { // After 10 tries, just throw the exception (usually only once is required) if (count++ > 10) throw; Thread.Sleep(50); // Give the dialog time to finish whatever caused this exception } } } } }
public BackgroundWorker(MinimizeResultsDlg dlg, ILongWaitBroker longWaitBroker) { _dlg = dlg; _longWaitBroker = longWaitBroker; }