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 | Properties | List of all members
NSFTimerThread Class Reference

Represents a timer thread. More...

Inheritance diagram for NSFTimerThread:
NSFThread NSFTaggedObject NSFUniquelyNumberedObject INSFNamedObject

Public Member Functions

 NSFTimerThread (NSFString name)
 Creates a timer thread. More...
 
bool isScheduled (NSFTimerAction action)
 Checks if an action is scheduled. More...
 
void scheduleAction (NSFTimerAction action)
 Schedules an action to execute at its previously designated execution time. More...
 
void scheduleAction (NSFTimerAction action, NSFTime delayTime, NSFTime repeatTime)
 Schedules an action with the timer. More...
 
override void terminate (bool waitForTerminated)
 Terminates the thread by causing the execution method to return. More...
 
void unscheduleAction (NSFTimerAction action)
 Unschedules a previously scheduled action. 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< NSFContextTimeGapActions = new NSFVoidActions<NSFContext>()
 Actions to be executed whenever the timer encounters delay greater than MaxAllowableTimeGap in processing actions. 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 Member Functions

override void threadLoop ()
 Implements the main timer 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

NSFTime CurrentTime [get]
 Gets the current time. More...
 
int MaxAllowableTimeGap [get, set]
 Gets or sets the maximum allowable delay the timer can see before firing the TimeGapActions. More...
 
NSFTime MaxObservedTimeGap [get, set]
 Gets or sets the maximum observed delay in executing timer actions. More...
 
NSFOSTimer Timer [get]
 Gets the underlying timer. More...
 
static NSFTimerThread PrimaryTimerThread [get]
 Gets the primary timer thread of the North State Framework. 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...
 
- Protected Attributes inherited from NSFThread
object threadMutex = new object()
 

Detailed Description

Represents a timer thread.

A timer thread contains a list of timer actions to execute at specified times.

Constructor & Destructor Documentation

Creates a timer thread.

Parameters
nameUser specified name for timer.

Member Function Documentation

bool isScheduled ( NSFTimerAction  action)

Checks if an action is scheduled.

Parameters
actionThe action in question.
Returns
True if the action is scheduled, otherwise false.
void scheduleAction ( NSFTimerAction  action)

Schedules an action to execute at its previously designated execution time.

Parameters
actionThe action to schedule.
void scheduleAction ( NSFTimerAction  action,
NSFTime  delayTime,
NSFTime  repeatTime 
)

Schedules an action with the timer.

Parameters
actionThe action to schedule.
delayTimeThe delay time before the action should execute.
repeatTimeThe repeat time if the action is periodic, or 0 if the action is non-periodic.
override 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 from NSFThread.

override void threadLoop ( )
protectedvirtual

Implements the main timer processing loop.

Implements NSFThread.

void unscheduleAction ( NSFTimerAction  action)

Unschedules a previously scheduled action.

Parameters
actionThe action to unschedule.

Unscheduling an action that is not currently scheduled has no effect.

Member Data Documentation

NSFVoidActions<NSFContext> TimeGapActions = new NSFVoidActions<NSFContext>()

Actions to be executed whenever the timer encounters delay greater than MaxAllowableTimeGap in processing actions.

In a well behaved system this event should not fire. It is provided for diagnostic purposes.

Property Documentation

NSFTime CurrentTime
get

Gets the current time.

int MaxAllowableTimeGap
getset

Gets or sets the maximum allowable delay the timer can see before firing the TimeGapActions.

This property specifies the time in milli-seconds. Set to zero to disable.

NSFTime MaxObservedTimeGap
getset

Gets or sets the maximum observed delay in executing timer actions.

NSFTimerThread PrimaryTimerThread
staticget

Gets the primary timer thread of the North State Framework.

Although it is possible to create additional timers, this is very rare and should be carefully considered if it is necessary.

NSFOSTimer Timer
get

Gets the underlying timer.




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