示例#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
        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);
            }
        }
示例#3
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;
              }
        }
示例#4
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);
              }
        }