Example #1
0
        /// <summary>
        /// Creates a scheduled action.
        /// </summary>
        /// <param name="name">The name of the scheduled action.</param>
        /// <param name="action">The action to execute.</param>
        /// <param name="eventThread">The thread on which the action will execute.</param>
        /// <remarks>
        /// Use null or String.Empty for the name if no name is desired.
        /// The action will be logged in the trace if the name is anything other than null or String.Empty.
        /// </remarks>
        public NSFScheduledAction(NSFString name, NSFVoidAction <NSFContext> action, NSFEventThread eventThread)
            : base(name)
        {
            Actions += action;
            Actions.setExceptionAction(handleActionException);

            eventHandler        = new NSFEventHandler(Name, eventThread);
            executeActionsEvent = new NSFEvent(Name, this, eventHandler);

            eventHandler.LoggingEnabled = false;
            eventHandler.addEventReaction(executeActionsEvent, executeActions);

            eventHandler.startEventHandler();
        }
        /// <summary>
        /// Creates a state.
        /// </summary>
        /// <param name="name">The name of the state.</param>
        /// <param name="parentRegion">The parent region of the state.</param>
        /// <param name="entryAction">The actions to be performed upon entry to the state.</param>
        /// <param name="exitAction">The actions to be performed upon exit of the state.</param>
        public NSFState(NSFString name, NSFRegion parentRegion, NSFVoidAction <NSFStateMachineContext> entryAction, NSFVoidAction <NSFStateMachineContext> exitAction)
            : base(name)
        {
            this.parentRegion = parentRegion;
            EntryActions     += entryAction;
            ExitActions      += exitAction;

            if (parentRegion != null)
            {
                parentRegion.addSubstate(this);
            }

            EntryActions.setExceptionAction(handleEntryActionException);
            ExitActions.setExceptionAction(handleExitActionException);
        }