Exemplo n.º 1
0
        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
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 public BackgroundWorker(MinimizeResultsDlg dlg, ILongWaitBroker longWaitBroker)
 {
     _dlg            = dlg;
     _longWaitBroker = longWaitBroker;
 }
Exemplo n.º 3
0
 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
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
 public BackgroundWorker(MinimizeResultsDlg dlg, ILongWaitBroker longWaitBroker)
 {
     _dlg = dlg;
     _longWaitBroker = longWaitBroker;
 }