コード例 #1
0
        /// <summary>
        /// Show wait form. Call it at times when UI thread will be unresponsible
        /// For now used 1. on Executing commands through the CommandManager
        ///              2. when creating and showing child forms
        /// </summary>
        /// <param name="text">message body, optional</param>
        /// <param name="header">message header, optional</param>
        /// <param name="steps">overall steps provide to show progress bar, and on each step call IncProcessingState(), optional</param>
        public void ShowProcessing(string text = "", string header = "", int steps = 0)
        {
            targetProcessingSteps = steps;
            currentProcessingStep = 0;

            appWaitForm = GetNewAppWaitForm();

            queueAppWaitForm.Enqueue(appWaitForm);

            if (!appWaitForm.Visible)
            {
                Task.Run(() => InvokeIfRequired(appWaitForm, () =>
                {
                    try
                    {
                        barButtonStatusNotifications.Enabled = false;
                        appWaitForm.ShowDialog();
                    }
                    catch (InvalidOperationException e)
                    {
                        log.Warn(string.Concat(appWaitForm.GetType().Name, e.Message));
                    }
                }));
            }


            Application.DoEvents();
        }
コード例 #2
0
        /// <summary>
        /// Hide wait form, when UI thread will be responsible again
        /// </summary>
        public void HideProcessing()
        {
            if (queueAppWaitForm.Count > 0)
            {
                InvokeIfRequired(queueAppWaitForm.Peek(), () =>
                {
                    try
                    {
                        var tempAppWaitForm = queueAppWaitForm.Dequeue();

                        tempAppWaitForm.Close();
                        tempAppWaitForm.Dispose();
                        barButtonStatusNotifications.Enabled = true;
                    }
                    catch (InvalidOperationException e)
                    {
                        log.Warn(string.Concat(appWaitForm.GetType().Name, e.Message));
                    }
                });
            }

            Application.DoEvents();
        }
コード例 #3
0
        /// <summary>
        /// Show wait form. Call it at times when UI thread will be unresponsible
        /// For now used 1. on Executing commands through the CommandManager
        ///              2. when creating and showing child forms
        /// </summary>
        /// <param name="text">message body, optional</param>
        /// <param name="header">message header, optional</param>
        /// <param name="steps">overall steps provide to show progress bar, and on each step call IncProcessingState(), optional</param>
        public void ShowProcessing(string text = "", string header = "", int steps = 0)
        {
            targetProcessingSteps = steps;
            currentProcessingStep = 0;

            appWaitForm = GetNewAppWaitForm();

            queueAppWaitForm.Enqueue(appWaitForm);

            if(!appWaitForm.Visible)
            {
                Task.Run(() => InvokeIfRequired(appWaitForm, () =>
                {
                    try
                    {
                        barButtonStatusNotifications.Enabled = false;
                        appWaitForm.ShowDialog();
                    }
                    catch(InvalidOperationException e)
                    {
                        log.Warn(string.Concat(appWaitForm.GetType().Name, e.Message));
                    }
                }));
            }


            Application.DoEvents();
        }