North State Framework in C#
V3.0.0
An object-oriented framework for implementing UML state machines.
|
Represents a light-weight event handler. More...
Public Member Functions | |
NSFEventHandler (NSFString name, NSFEventThread thread) | |
Creates an event handler More... | |
void | addEventReaction (NSFEvent nsfEvent, NSFVoidAction< NSFEventContext > action) |
Adds a reaction to a specified event. More... | |
NSFEventStatus | handleEvent (NSFEvent nsfEvent) |
Handles an event. More... | |
bool | hasEvent (NSFEvent nsfEvent) |
Checks if an event is queued for handling. More... | |
bool | hasEvent () |
Checks if any events are queued for handling. More... | |
void | queueEvent (NSFEvent nsfEvent) |
Queues an event for the handler. More... | |
void | queueEvent (NSFEvent nsfEvent, INSFNamedObject source) |
Queues an event for the handler. More... | |
void | removeEventReaction (NSFEvent nsfEvent, NSFVoidAction< NSFEventContext > action) |
Removes a reaction to a specified event. More... | |
void | startEventHandler () |
Starts event processing. More... | |
void | stopEventHandler () |
Stops event processing. More... | |
void | terminate (bool waitForTerminated) |
Terminates the event handler, so that it can be garbage collected. More... | |
Public Member Functions inherited from NSFTaggedObject | |
NSFTaggedObject (NSFString name) | |
Creates an object with a unique id and a name. More... | |
Public Member Functions inherited from NSFUniquelyNumberedObject | |
NSFUniquelyNumberedObject () | |
Creates a uniquely numbered object. More... | |
bool | isSameObject (NSFUniquelyNumberedObject other) |
Checks if this object is the same as another object. More... | |
Properties | |
NSFEventHandlerRunStatus | RunStatus [get, set] |
NSFEventHandlerTerminationStatus | TerminationStatus [get, set] |
static uint | TerminationSleepTime [get, set] |
Gets the amount of time (mS) the terminate method sleeps between checks for event handler termination. More... | |
static int | TerminationTimeout [get, set] |
The amount of time the terminate method will wait for event processing to complete. More... | |
NSFEventThread | EventThread [get, set] |
Gets or sets the event handler's thread. More... | |
bool | LoggingEnabled [get, set] |
Gets or sets the flag indicating if event logging is enabled. More... | |
Properties inherited from NSFTaggedObject | |
NSFString | Name [get, set] |
Properties inherited from NSFUniquelyNumberedObject | |
NSFId | UniqueId [get] |
Gets or sets the unique id of the object. More... | |
Properties inherited from INSFNamedObject | |
NSFString | Name [get] |
Gets the name of the object. More... | |
Properties inherited from INSFEventHandler | |
NSFEventHandlerRunStatus | RunStatus [get] |
Gets the run status of the event handler. More... | |
NSFEventHandlerTerminationStatus | TerminationStatus [get] |
Gets the termination status of the event handler. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from NSFUniquelyNumberedObject | |
static NSFId | getNextUniqueId () |
Gets the next unique id. More... | |
Represents a light-weight event handler.
This class associates actions with events, executing the actions when the event is handled. Events are queued to the specified thread and handled in the order they are received. Actions execute on the specified thread. This class is a light-weight event handler which can be used instead of a state machine.
NSFEventHandler | ( | NSFString | name, |
NSFEventThread | thread | ||
) |
Creates an event handler
name | The user defined name for the state machine. |
thread | The thread on which events for the state machine are queued. |
void addEventReaction | ( | NSFEvent | nsfEvent, |
NSFVoidAction< NSFEventContext > | action | ||
) |
Adds a reaction to a specified event.
nsfEvent | The event causing the action. |
action | The action taken as a result of the event. |
NSFEventStatus handleEvent | ( | NSFEvent | nsfEvent | ) |
Handles an event.
nsfEvent | The event to handle. |
This method is for use only by the North State Framework's internal logic. It calls the actions associated with the event, if any.
Implements INSFEventHandler.
bool hasEvent | ( | NSFEvent | nsfEvent | ) |
Checks if an event is queued for handling.
nsfEvent | The event in queustion. |
bool hasEvent | ( | ) |
Checks if any events are queued for handling.
void queueEvent | ( | NSFEvent | nsfEvent | ) |
Queues an event for the handler.
nsfEvent | The event to queue. |
Implements INSFEventHandler.
void queueEvent | ( | NSFEvent | nsfEvent, |
INSFNamedObject | source | ||
) |
Queues an event for the handler.
nsfEvent | The event to queue. |
source | The source of the event. |
Implements INSFEventHandler.
void removeEventReaction | ( | NSFEvent | nsfEvent, |
NSFVoidAction< NSFEventContext > | action | ||
) |
Removes a reaction to a specified event.
nsfEvent | The event causing the action. |
action | The action taken as a result of the event. |
void startEventHandler | ( | ) |
Starts event processing.
When stopped, events queued prior to calling the method startEventHandler() will be dropped. Events queued after calling the method startEventHandler() will be processed, until the next call to stopEventHandler(). When started, events queued prior to calling the method stopEventHandler() will be processed. Events queued after calling the method stopEventHandler() will be dropped, until the next call to startEventHandler().
Implements INSFEventHandler.
void stopEventHandler | ( | ) |
Stops event processing.
When stopped, events queued prior to calling the method startEventHandler() will be dropped. Events queued after calling the method startEventHandler() will be processed, until the next call to stopEventHandler(). When started, events queued prior to calling the method stopEventHandler() will be processed. Events queued after calling the method stopEventHandler() will be dropped, until the next call to startEventHandler().
Implements INSFEventHandler.
void terminate | ( | bool | waitForTerminated | ) |
Terminates the event handler, so that it can be garbage collected.
waitForTerminated | Flag indicating if the method should wait until the event handler is terminated (true), or if it should return immediately (false). |
This method terminates the event handler in a coordinated fashion, making sure all remaining events are cleared, so that it can be garbage collected. After calling this method, the event handler cannot be restarted. This method should only be called if the event handler should be garbage collected. If the waitForTerminated flag is set true, this method must not be called from the event handler's thread of execution.
Implements INSFEventHandler.
|
getset |
Gets or sets the event handler's thread.
|
getset |
Gets or sets the flag indicating if event logging is enabled.
|
getset |
|
staticgetset |
Gets the amount of time (mS) the terminate method sleeps between checks for event handler termination.
|
getset |
|
staticgetset |
The amount of time the terminate method will wait for event processing to complete.