Arduino countdown timer for repeating actions I have tried to find simple library for triggering timer after some time. 
The idea is to retry network connection (RF24 network library). 

I have following code now  

while(!mesh.write(message, headerType, memSize)) {

}


This code will try to send packet until success

But I need to give up after for instance 10 seconds 

I wanna to have something like this 

bool timerTriggered = false;
Timer myTimer = new Timer(10000);
myTimer.setCallback(countedDown);

void countedDown() {
   timerTriggered = true;
}


And start timer before network request 

myTimer.start();

while(!mesh.write(message, headerType, memSize) || !timerTriggered) {

}


Please suggest the best way to implement this. 

Thanks.

EDIT

I have found problem as far as delay(); uses timer internally it conflicts with libraries or simple timer. 

The solution is to use Alarm.delay(400); instead.

Maybe someone knows better solution ?
Something like this would work as a non-blocking, general purpose timer:

unsigned long startTimestamp;
unsigned long timestamp;
const unsigned long timer_length = 10000; //10 seconds

startTimestamp = millis();
timestamp = startTimestamp;

while ( (timestamp - startTimestamp) &lt; timer_length)
{
    // keep doing thing

    timestamp = millis();
}

// stop doing thing now