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

Used to determine the timing in which a task is exited.

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

Syntax

C#
public enum ExitTiming
Visual Basic (Declaration)
Public Enumeration ExitTiming
Visual C++
public enum class ExitTiming

Members

Member nameDescription
BeforeRow
After the row is loaded, but before the EnterRow event.
AfterRow
After the row is saved to the Database
AsSoonAsPossible
As soon as possible

Examples

Usage of exit
This example is in the form of Unit Tests. It references the NUnit framework. This framework can be downloaded from www.NUnit.org. For more information about unit testing visit: www.NUnit.org.
CopyC#
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using Firefly.Box;
using Firefly.Box.Testing;

namespace TestFirefly.Box.Documentation
{
    [TestFixture]
    public class Exit
    {
        [Test]
        public void UsingExitWithoutParameters()
        {
            var bp = new BusinessProcess();
            int cycles = 0;
            bp.LeaveRow += () =>
                             {
                                 cycles++;
                                 if (cycles > 5)
                                     bp.Exit();
                             };
            bp.Run();
            cycles.ShouldBe(6);
        }
        [Test]
        public void UsingExitBeforeTheTaskRuns()
        {
            var bp = new BusinessProcess();
            bool startEventHappened = false;
            bool enterRowEventHappened = false;
            bp.Start += () => startEventHappened = true;
            bp.EnterRow += () => enterRowEventHappened = true;
            bp.Exit();
            bp.Run();
            startEventHappened.ShouldBe(true);//The start event happens regardless of the exit command, 
            //as the exit command is evaluated at the row level.
            enterRowEventHappened.ShouldBe(false);//The enter row event didn't happen, because the task was instructed to exit.
        }
        [Test]
        public void UsingExitWithBeforeEnterRowTiming()
        {
            var bp = new BusinessProcess();
            bool startEventHappened = false;
            bool enterRowEventHappened = false;
            bp.Start += () => startEventHappened = true;
            bp.EnterRow += () => enterRowEventHappened = true;
            bp.Exit(ExitTiming.BeforeRow); //The default value, acts the same as without any parameters
            bp.Run();
            startEventHappened.ShouldBe(true);//The start event happens regardless of the exit command, 
            //as the exit command is evaluated at the row level.
            enterRowEventHappened.ShouldBe(false);//The enter row event didn't happen, because the task was instructed to exit.
        }
        [Test]
        public void UsingExitWithAflterLeaveRowTiming()
        {
            var bp = new BusinessProcess();
            bool leaveRowHappened = false;
            bp.LeaveRow += () => leaveRowHappened = true;
            bp.Exit(ExitTiming.AfterRow);
            bp.Run();
            leaveRowHappened.ShouldBe(true);
        }
        [Test]
        public void UsingExitWithAflterLeaveRowTimingAndACondition()
        {
            var bp = new BusinessProcess();
            int cycles = 0;
            bp.LeaveRow += () =>
                {
                    cycles++;
                };
            bp.Exit(ExitTiming.AfterRow, () => cycles > 5);
            bp.Run();
            cycles.ShouldBe(6);
        }
    }
}

See Also