Inheritance: DialogForm
Beispiel #1
0
        public HResult ShowWaitDialog(string caption, string message, string progressText, string statusBarText, TimeSpan showDelay, bool canCancel, bool realProgress, float progress, IntPtr[] waitHandles)
        {
            try
            {
                if (waitHandles == null)
                    throw new ArgumentNullException("waitHandles");
                if (waitHandles.Length == 0)
                    throw new ArgumentException("Wait handles cannot be of zero length");
                if (_showing)
                    throw new InvalidOperationException("Wait dialog is already showing");

                _showing = true;

                try
                {
                    if (statusBarText != null)
                        SetStatusBarText(statusBarText);

                    int delay = (int)showDelay.TotalMilliseconds;

                    if (WaitForHandles(waitHandles, ref delay, WaitBeforeWaitCursor))
                        return HResult.OK;

                    Application.UseWaitCursor = true;
                    Cursor.Current = Cursors.WaitCursor;
                    Application.DoEvents();

                    try
                    {
                        if (WaitForHandles(waitHandles, ref delay, delay))
                            return HResult.OK;

                        _form = new WaitDialogForm(_synchronizationContext, caption, message, progressText, canCancel, realProgress, progress, waitHandles);

                        try
                        {
                            _cancelled = _form.ShowDialog(_serviceProvider) != DialogResult.OK;
                        }
                        finally
                        {
                            _form.Dispose();
                            _form = null;
                        }
                    }
                    finally
                    {
                        Application.UseWaitCursor = false;
                        Cursor.Current = Cursors.Default;

                        SetStatusBarText(null);
                    }
                }
                finally
                {
                    _showing = false;
                }

                return HResult.OK;
            }
            catch (Exception ex)
            {
                return ErrorUtil.GetHResult(ex);
            }
        }
Beispiel #2
0
        public HResult ShowWaitDialog(string caption, string message, string progressText, string statusBarText, TimeSpan showDelay, bool canCancel, bool realProgress, float progress, IntPtr[] waitHandles)
        {
            try
            {
                if (waitHandles == null)
                {
                    throw new ArgumentNullException("waitHandles");
                }
                if (waitHandles.Length == 0)
                {
                    throw new ArgumentException("Wait handles cannot be of zero length");
                }
                if (_showing)
                {
                    throw new InvalidOperationException("Wait dialog is already showing");
                }

                _showing = true;

                try
                {
                    if (statusBarText != null)
                    {
                        SetStatusBarText(statusBarText);
                    }

                    int delay = (int)showDelay.TotalMilliseconds;

                    if (WaitForHandles(waitHandles, ref delay, WaitBeforeWaitCursor))
                    {
                        return(HResult.OK);
                    }

                    Application.UseWaitCursor = true;
                    Cursor.Current            = Cursors.WaitCursor;
                    Application.DoEvents();

                    try
                    {
                        if (WaitForHandles(waitHandles, ref delay, delay))
                        {
                            return(HResult.OK);
                        }

                        _form = new WaitDialogForm(_synchronizationContext, caption, message, progressText, canCancel, realProgress, progress, waitHandles);

                        try
                        {
                            _cancelled = _form.ShowDialog(_serviceProvider) != DialogResult.OK;
                        }
                        finally
                        {
                            _form.Dispose();
                            _form = null;
                        }
                    }
                    finally
                    {
                        Application.UseWaitCursor = false;
                        Cursor.Current            = Cursors.Default;

                        SetStatusBarText(null);
                    }
                }
                finally
                {
                    _showing = false;
                }

                return(HResult.OK);
            }
            catch (Exception ex)
            {
                return(ErrorUtil.GetHResult(ex));
            }
        }