예제 #1
0
        void ProgressDialogTestWithCancelButton()
        {
            // Easy way to pass data to the async method
            int millisecondsTimeout = 1500;

            ProgressDialogResult result = ProgressDialog.Execute(this, "Loading data", (bw, we) => {
                for (int i = 1; i <= 5; i++)
                {
                    if (ProgressDialog.ReportWithCancellationCheck(bw, we, "Executing step {0}/5...", i))
                    {
                        return;
                    }

                    Thread.Sleep(millisecondsTimeout);
                }

                // So this check in order to avoid default processing after the Cancel button has been pressed.
                // This call will set the Cancelled flag on the result structure.
                ProgressDialog.CheckForPendingCancellation(bw, we);
            }, ProgressDialogSettings.WithSubLabelAndCancel);

            if (result.Cancelled)
            {
                MessageBox.Show("ProgressDialog cancelled.");
            }
            else if (result.OperationFailed)
            {
                MessageBox.Show("ProgressDialog failed.");
            }
            else
            {
                MessageBox.Show("ProgressDialog successfully executed.");
            }
        }
예제 #2
0
        internal static ProgressDialogResult ExecuteInternal(Window owner, string label, object operation, ProgressDialogSettings settings)
        {
            ProgressDialog dialog = new ProgressDialog(settings);

            dialog.Owner = owner;

            if (!string.IsNullOrEmpty(label))
            {
                dialog.Label = label;
            }

            return(dialog.Execute(operation));
        }
예제 #3
0
        void ProgressDialogTestDefault()
        {
            ProgressDialogResult result = ProgressDialog.Execute(this, "Loading data...", (bw, we) => {
                Thread.Sleep(4000);
            });

            if (result.OperationFailed)
            {
                MessageBox.Show("ProgressDialog failed.");
            }
            else
            {
                MessageBox.Show("ProgressDialog successfully executed.");
            }
        }
예제 #4
0
        void ProgressDialogTestWithSubLabel()
        {
            ProgressDialogResult result = ProgressDialog.Execute(this, "Loading data", (bw) => {
                for (int i = 1; i <= 5; i++)
                {
                    ProgressDialog.Report(bw, "Executing step {0}/5...", i);

                    Thread.Sleep(1500);
                }
            }, ProgressDialogSettings.WithSubLabel);

            if (result.OperationFailed)
            {
                MessageBox.Show("ProgressDialog failed.");
            }
            else
            {
                MessageBox.Show("ProgressDialog successfully executed.");
            }
        }
        internal static ProgressDialogResult ExecuteInternal(Window owner, string label, object operation, ProgressDialogSettings settings)
        {
            ProgressDialog dialog = new ProgressDialog(settings);
            dialog.Owner = owner;

            if (!string.IsNullOrEmpty(label))
                dialog.Label = label;

            return dialog.Execute(operation);
        }