コード例 #1
0
        public static DialogResult ShowModal(String title, String message, bool animated,
                                             ReadyDelegate notifyReady, CancelDelegate deleg)
        {
            using (HUDForm instance = new HUDForm())
            {
                // Don't use lock() here as we might dead lock otherwise.
                if (!Monitor.TryEnter(instanceLock))
                {
                    Application.DoEvents(); // See if we can let the application finish pending stuff first.
                    if (!Monitor.TryEnter(instanceLock))
                    {
                        return(DialogResult.Abort); // Still no lock possible? In this case we can only leave without showing the HUD form.
                    }
                }

                currentInstance = instance;
                Monitor.Exit(instanceLock);

                instance.label1.Text    = title;
                instance.label2.Text    = message;
                instance.cancelDelegate = deleg;

                // Can happen the form is cancelled already while we are still doing the setup
                // (separate thread).
                if (instance.IsDisposed || instance.Disposing)
                {
                    if (Monitor.TryEnter(instanceLock))
                    {
                        currentInstance = null;
                        Monitor.Exit(instanceLock);
                    }
                    return(DialogResult.Abort);
                }

                instance.Reshow(animated, true);

                // Need to set Visible back to false to avoid an exception in ShowDialog about an already
                // visible window. Doesn't usually have a visual effect.
                instance.Visible = false;

                if (notifyReady != null)
                {
                    notifyReady();
                }

                DialogResult result = DialogResult.Abort;
                if (!instance.IsDisposed && !instance.Disposing)
                {
                    result = instance.ShowDialog();
                }
                if (Monitor.TryEnter(instanceLock))
                {
                    instance.Dispose();
                    currentInstance = null;
                    Monitor.Exit(instanceLock);
                }

                return(result);
            }
        }
コード例 #2
0
 /// <summary>
 /// Hide the HUD and return OK as dialog result.
 /// Always called in the context of the main thread with active lock.
 /// </summary>
 protected void DoFinish()
 {
     if (IsHandleCreated)
     {
         Hide();
     }
     this.DialogResult = DialogResult.Abort;
     Dispose();
     currentInstance = null;
 }
コード例 #3
0
        public static void Show(String title, String message, bool animated)
        {
            lock (instanceLock) // Hard lock here. Must never happen.
            {
                HUDForm instance = new HUDForm();
                currentInstance      = instance;
                instance.label1.Text = title;
                instance.label2.Text = message;

                instance.Reshow(animated, false);
            }
        }
コード例 #4
0
ファイル: HUDForm.cs プロジェクト: abibell/mysql-workbench
 /// <summary>
 /// Hide the HUD and return OK as dialog result.
 /// Always called in the context of the main thread with active lock.
 /// </summary>
 protected void DoFinish()
 {
     if (IsHandleCreated)
     Hide();
       this.DialogResult = DialogResult.Abort;
       Dispose();
       currentInstance = null;
 }
コード例 #5
0
ファイル: HUDForm.cs プロジェクト: abibell/mysql-workbench
        public static DialogResult ShowModal(String title, String message, bool animated,
            ReadyDelegate notifyReady, CancelDelegate deleg)
        {
            using (HUDForm instance = new HUDForm())
              {
            // Don't use lock() here as we might dead lock otherwise.
            if (!Monitor.TryEnter(instanceLock))
            {
              Application.DoEvents(); // See if we can let the application finish pending stuff first.
              if (!Monitor.TryEnter(instanceLock))
            return DialogResult.Abort; // Still no lock possible? In this case we can only leave without showing the HUD form.
            }

            currentInstance = instance;
            Monitor.Exit(instanceLock);

            instance.label1.Text = title;
            instance.label2.Text = message;
            instance.cancelDelegate = deleg;

            // Can happen the form is cancelled already while we are still doing the setup
            // (separate thread).
            if (instance.IsDisposed || instance.Disposing)
            {
              if (Monitor.TryEnter(instanceLock))
              {
            currentInstance = null;
            Monitor.Exit(instanceLock);
              }
              return DialogResult.Abort;
            }

            instance.Reshow(animated, true);

            // Need to set Visible back to false to avoid an exception in ShowDialog about an already
            // visible window. Doesn't usually have a visual effect.
            instance.Visible = false;

            if (notifyReady != null)
              notifyReady();

            DialogResult result = DialogResult.Abort;
            if (!instance.IsDisposed && !instance.Disposing)
              result = instance.ShowDialog();
            if (Monitor.TryEnter(instanceLock))
            {
              instance.Dispose();
              currentInstance = null;
              Monitor.Exit(instanceLock);
            }

            return result;
              }
        }
コード例 #6
0
ファイル: HUDForm.cs プロジェクト: abibell/mysql-workbench
        public static void Show(String title, String message, bool animated)
        {
            lock (instanceLock) // Hard lock here. Must never happen.
              {
            HUDForm instance = new HUDForm();
            currentInstance = instance;
            instance.label1.Text = title;
            instance.label2.Text = message;

            instance.Reshow(animated, false);
              }
        }