North State Framework in C#  V3.0.0
An object-oriented framework for implementing UML state machines.
Public Member Functions | Protected Member Functions | Properties | List of all members
NSFEventThread Class Reference

Represents a thread that has an event queue and dispatches events to their destinations. More...

Inheritance diagram for NSFEventThread:
NSFThread NSFTaggedObject NSFUniquelyNumberedObject INSFNamedObject

Public Member Functions

 NSFEventThread (NSFString name)
 Creates an event thread. More...
 
 NSFEventThread (NSFString name, int priority)
 Creates an event thread. More...
 
bool hasEvent (NSFEvent nsfEvent)
 Indicates if the event queue contains an event that matches the specified event. More...
 
bool hasEventFor (INSFEventHandler eventHandler)
 Indicates if the event queue contains an event for the specified destination. More...
 
void removeEventsFor (INSFEventHandler eventHandler)
 Removes all events for the specified event handler. More...
 
void queueEvent (NSFEvent nsfEvent, bool isPriorityEvent, bool logEventQueued)
 Queues the specified event. More...
 
override void terminate (bool waitForTerminated)
 Terminates the thread by causing the thread loop to return. 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...
 

Protected Member Functions

override void threadLoop ()
 Implements the main event processing loop. More...
 
- Protected Member Functions inherited from NSFThread
 NSFThread (NSFString name)
 Creates a thread. More...
 
 NSFThread (NSFString name, int priority)
 Creates an event thread. More...
 
void handleException (Exception exception)
 Handles exceptions caught by main event processing loop. More...
 
void startThread ()
 Starts the thread by calling its execution action. More...
 

Properties

List< INSFEventHandlerEventHandlers [get]
 Gets a list of event handlers using the thread. More...
 
- Properties inherited from NSFThread
NSFOSThread OSThread [get, set]
 Gets the underlying OS thread. More...
 
NSFThreadTerminationStatus TerminationStatus [get, set]
 Gets the thread termination status. More...
 
static uint TerminationSleepTime [get, set]
 Gets the amount of time (mS) the terminate method sleeps between checks for thread termination. More...
 
static int TerminationTimeout [get, set]
 The amount of time the terminate method will wait for event processing to complete. 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...
 

Additional Inherited Members

- Static Public Member Functions inherited from NSFUniquelyNumberedObject
static NSFId getNextUniqueId ()
 Gets the next unique id. More...
 
- Public Attributes inherited from NSFThread
NSFVoidActions
< NSFExceptionContext
ExceptionActions = new NSFVoidActions<NSFExceptionContext>()
 Actions to execute if an exception is encountered while the thread is executing. More...
 
- Protected Attributes inherited from NSFThread
object threadMutex = new object()
 

Detailed Description

Represents a thread that has an event queue and dispatches events to their destinations.

Constructor & Destructor Documentation

Creates an event thread.

Parameters
nameThe name of the thread.

The thread is created with medium priority. To change the priority, use the Thread property to access the underlying thread object.

NSFEventThread ( NSFString  name,
int  priority 
)

Creates an event thread.

Parameters
nameThe name of the thread.
priorityThe priority of the thread.

Member Function Documentation

bool hasEvent ( NSFEvent  nsfEvent)

Indicates if the event queue contains an event that matches the specified event.

Parameters
nsfEventThe event to match.
Returns
True if the event queue contains a matching event, false otherwise.

Two events match if they have the same id. Events may be copied to create new events with the same id.

bool hasEventFor ( INSFEventHandler  eventHandler)

Indicates if the event queue contains an event for the specified destination.

Parameters
eventHandlerThe event handler destination.
Returns
True if the event queue contains an event with the specified destination, false otherwise.
void queueEvent ( NSFEvent  nsfEvent,
bool  isPriorityEvent,
bool  logEventQueued 
)

Queues the specified event.

Parameters
nsfEventThe event to queue.
isPriorityEventFlag indicating if the event should be queued to the back of the queue (false) or the front of the queue (true).
logEventQueuedFlag indicating if an event queued trace should be added to the trace log.
void removeEventsFor ( INSFEventHandler  eventHandler)

Removes all events for the specified event handler.

Parameters
eventHandlerThe event handler destination.
override void terminate ( bool  waitForTerminated)
virtual

Terminates the thread by causing the thread loop to return.

Parameters
waitForTerminatedFlag indicating if the method should wait until the event thread is terminated (true), or if it should return immediately (false).

This method is useful to guarantee that a thread is no longer active, so that it can be garbage collected. If the waitForTerminated flag is set true, this method must not be called from its thread of execution. Before terminating the event thread, this method terminates all event handlers using the thread.

Reimplemented from NSFThread.

override void threadLoop ( )
protectedvirtual

Implements the main event processing loop.

Implements NSFThread.

Property Documentation

List<INSFEventHandler> EventHandlers
get

Gets a list of event handlers using the thread.




Copyright 2004-2014, North State Software, LLC. All rights reserved.