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

  interval | The execution interval.
  action | The action to execute.

References CommandMessenger.TimedAction.IsRunning.

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

## Member Function Documentation

void CommandMessenger.TimedAction.Start | ( |  | ) |

inline

Start timed actions.

{
// Start interval events
_actionTimer.Enabled = true;
}

void CommandMessenger.TimedAction.Stop | ( |  | ) |

inline

Stop timed actions.

{
// Halt new interval events
_actionTimer.Enabled = false;
}

void CommandMessenger.TimedAction.StopAndWait | ( |  | ) |

inline

Stop timed actions and wait until running function has finished.

{
// Halt new interval events
_actionTimer.Enabled = false;
while (_threadState.IsRunning)
{
}
}

## 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:

- D:/My Documents/Github/Arduino-Code-and-Libraries/Libraries/CmdMessenger/CSharp/CommandMessenger/TimedAction.cs