[This is preliminary documentation and is subject to change.]

Gets or sets the value determining if the BusinessProcess will listen to certain inputs from the user that will cause it to terminate.

Namespace:  Firefly.Box
Assembly:  Firefly.Box (in Firefly.Box.dll) Version: 3.4.23.6473 (3.4.23.6473)

Syntax

C#
public bool AllowUserAbort { get; set; }
Visual Basic (Declaration)
Public Property AllowUserAbort As Boolean
Visual C++
public:
property bool AllowUserAbort {
	bool get ();
	void set (bool value);
}

Remarks

Gets or sets the value determining if the BusinessProcess will listen to certain inputs from the user that will cause it to terminate. Those inputs are:
  • The user presses the Escape key on the keyboard
  • The Exit command is raised
  • The ExitApplication command is raised
  • The user clicks on another form that is open

Examples

Usage of AllowUserAbort
CopyC#
using System;
using System.Drawing;
using System.Windows.Forms;
using Firefly.Box;


namespace TestFirefly.Box.Documentation
{
    public class DemoAllowUserAbort
    {
        public void Demonstration()
        {
            var label =
                new Label
                    {
                        Text = "This demonstration will demo the usage of AllowUserAbort.\n" +
                               "When the CheckBox is checked you should be able to stop the running process.\n" +
                               "Set the CheckBox, and click the run button to see the affect." +
                               "Try stopping the process by clicking the Escape Key, or by clicking on this Form.\n",
                        Width = 500,
                        Height = 50
                    };

            var checkBox = new CheckBox
                               {
                                   Top = label.Bottom + 5,
                                   Text = "AllowAbout",
                                   Checked = true
                               };


            var button = new Button
                             {
                                 Top = checkBox.Bottom + 5,
                                 Text = "Click Me To Run",
                                 Width = 300
                             };
            button.Click += (a, b) =>
                                {
                                    var bp = new BusinessProcess();
                                    var start = DateTime.Now;
                                    bp.AllowUserAbort = checkBox.Checked;
                                    MessageBox.Show("Starting The Process");
                                    bp.ForEachRow(delegate
                                                      {
                                                          if ((DateTime.Now - start).TotalSeconds > 10)
                                                          {
                                                              bp.Exit();
                                                          }
                                                      });
                                    if ((DateTime.Now - start).TotalSeconds > 10)
                                    {
                                        button.Text = "Completed - Click to run again";
                                        MessageBox.Show("The BusinessProcess completed without interference");
                                    }
                                    else
                                    {
                                        button.Text = "Interrupted - Click to run again";
                                        MessageBox.Show("The BusinessProcess was interrupted by the user");
                                    }
                                };
            var uic = new UIController();
            uic.View = new Firefly.Box.UI.Form
                            {
                                ClientSize = new Size(500, button.Bottom + 10)
                            };
            uic.View.Controls.AddRange(new Control[] { label, checkBox, button });
            uic.Run();
        }
    }
}

See Also