CmdMessenger  3.0
CmdMessenger is a serial port messaging library for the Arduino
Classes | Public Member Functions | Properties | List of all members
CommandMessenger.TimedAction Class Reference

Starts a recurring action with fixed interval If still running at next call, the action is skipped More...

Public Member Functions

 TimedAction (double interval, Action action)
 Constructor. More...
 
void Start ()
 Start timed actions. More...
 
void Stop ()
 Stop timed actions. More...
 
void StopAndWait ()
 Stop timed actions and wait until running function has finished. More...
 

Properties

bool IsRunning [get]
 Returns whether this object is running. More...
 

Detailed Description

Starts a recurring action with fixed interval If still running at next call, the action is skipped

Constructor & Destructor Documentation

CommandMessenger.TimedAction.TimedAction ( double  interval,
Action  action 
)
inline

Constructor.

Parameters
intervalThe execution interval.
actionThe action to execute.

References CommandMessenger.TimedAction.IsRunning.

57  {
58  _action = action;
59  _threadState = new ThreadState {IsRunning = false};
60 
61 
62  _actionTimer = new Timer(interval) {Enabled = false, SynchronizingObject = null};
63  _actionTimer.Elapsed += OnActionTimer;
64  }
bool IsRunning
Returns whether this object is running.
Definition: TimedAction.cs:49

Member Function Documentation

void CommandMessenger.TimedAction.Start ( )
inline

Start timed actions.

125  {
126  // Start interval events
127  _actionTimer.Enabled = true;
128  }
void CommandMessenger.TimedAction.Stop ( )
inline

Stop timed actions.

132  {
133  // Halt new interval events
134  _actionTimer.Enabled = false;
135  }
void CommandMessenger.TimedAction.StopAndWait ( )
inline

Stop timed actions and wait until running function has finished.

139  {
140  // Halt new interval events
141  _actionTimer.Enabled = false;
142  while (_threadState.IsRunning)
143  {
144  }
145  }

Property Documentation

bool CommandMessenger.TimedAction.IsRunning
get

Returns whether this object is running.

true if this object is running, false if not.

Referenced by CommandMessenger.TimedAction.TimedAction().


The documentation for this class was generated from the following file: