# Real-Time Robotics Framework

### Sidebar

getting_started:practical_problems:seq_endless

# Do not use Endless Loops in Sequences

Though a sequence might run endlessly - or at least as long as a robot is powered - it should be avoided to write something like

public:
int action() {
while (true) step1();
}

when defining the method action of the sequence. Due to some extraordinary condition such as a fault or stopping the application prematurely the sequence should stop as soon as the sequencer itself stops together with all its associated sequences. For this purpose the correct implementation of the action method is as follows:

public:
int action() {
while (getRunningState() == SequenceState::running) step1();
}

This also ensures that if a caller sequence stops due to a monitor, this sequence terminates as well.