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

Represents the common framework thread functionality. More...

Inheritance diagram for NSFThread:
NSFTaggedObject NSFUniquelyNumberedObject INSFNamedObject NSFEventThread NSFTimerThread

Public Member Functions

virtual void terminate (bool waitForTerminated)
 Terminates the thread by causing the execution method 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...
 

Public Attributes

NSFVoidActions
< NSFExceptionContext
ExceptionActions = new NSFVoidActions<NSFExceptionContext>()
 Actions to execute if an exception is encountered while the thread is executing. More...
 

Protected Member Functions

 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...
 
abstract void threadLoop ()
 Implements the main thread processing loop. More...
 

Protected Attributes

object threadMutex = new object()
 

Properties

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...
 

Detailed Description

Represents the common framework thread functionality.

Constructor & Destructor Documentation

NSFThread ( NSFString  name)
protected

Creates a thread.

Parameters
nameThe name of the thread.

The thread is created with medium priority. To change the priority, use the getOSThread() method to access the underlying thread object.

NSFThread ( NSFString  name,
int  priority 
)
protected

Creates an event thread.

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

Member Function Documentation

void handleException ( Exception  exception)
protected

Handles exceptions caught by main event processing loop.

Parameters
exceptionThe exception caught.
void startThread ( )
protected

Starts the thread by calling its execution action.

virtual void terminate ( bool  waitForTerminated)
virtual

Terminates the thread by causing the execution method to return.

Parameters
waitForTerminatedFlag indicating if the method should wait until the 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.

Reimplemented in NSFEventThread, and NSFTimerThread.

abstract void threadLoop ( )
protectedpure virtual

Implements the main thread processing loop.

Implemented in NSFEventThread, and NSFTimerThread.

Member Data Documentation

NSFVoidActions<NSFExceptionContext> ExceptionActions = new NSFVoidActions<NSFExceptionContext>()

Actions to execute if an exception is encountered while the thread is executing.

object threadMutex = new object()
protected

Property Documentation

NSFOSThread OSThread
getset

Gets the underlying OS thread.

uint TerminationSleepTime
staticgetset

Gets the amount of time (mS) the terminate method sleeps between checks for thread termination.

NSFThreadTerminationStatus TerminationStatus
getset

Gets the thread termination status.

int TerminationTimeout
staticgetset

The amount of time the terminate method will wait for event processing to complete.




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