Example #1
0
        /// <summary>
        /// Can be called from any thread
        /// </summary>
        private void UpdateBusyDisplay()
        {
            // If operation is taking too long and the busy window isn't showing, show it
            if (busyForm == null)
            {
                if (immediateBusyForm || workTimer.ElapsedMilliseconds > Program.Config.BusyWindowDelay)
                {
                    MainForm.Invoke((SimpleDelegate) delegate() {
                        busyForm = new frmBusy();
                        busyForm.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
                        busyForm.Left          = MainForm.Left + MainForm.Width / 2 - busyForm.Width / 2;
                        busyForm.Top           = MainForm.Top + MainForm.Height / 2 - busyForm.Height / 2;
                        busyForm.FormClosed   += new System.Windows.Forms.FormClosedEventHandler(busyForm_FormClosed);
                    });

                    MainForm.BeginInvoke((SimpleDelegate) delegate() {
                        if (Working)
                        {
                            busyForm.ShowDialog(MainForm);
                        }
                        else
                        {
                            busyForm.Dispose();
                            busyForm = null;
                        }
                    });
                }
            }
        }
Example #2
0
        /// <summary>
        /// To be called from UI thread only
        /// </summary>
        private void CloseBusyDisplay()
        {
            if (busyForm != null && !busyForm.IsDisposed)
            {
                busyForm.Close();
                busyForm.Dispose();
            }

            busyForm = null;
        }