Updating Display while waiting

Hi guys,
it seems quite easy but in some way I´m stuck - I need to find a way updating my (temperature) Display while waiting. Delay() obviously doesn´t work and with the Timer libraries I tried it didn´t come around (maybe just used in a wrong way). Anyways, to make it more concrete here is the code:

....
void loop(){
// receiving serial commands
switchByte = Serial.parseInt();
delayByte = Serial.parseInt();

//depending on switchByte it switches to either case 1 or 2
if (switchByte == 0){
state = 1;
}
else if(switchByte == 1){
state = 2;
}

switch (state){
case 1:
// Now it should take the delayByte (i.e. 3 seconds) and updating the Display (displayTemperature() ) while waiting, so I can´t use the delay function
?????

// after the 3 Seconds do something else
....
}

void displayTemperature(){
....
}

WOuld appreciate very much your help on that. Thanks!

Hello,

Look the Blink without delay example

While waiting for what? You really need to define your requirements. Reading two ints on every pass through loop() is a BAD idea. If nothing is available on the serial port, a bunch of time will be wasted and then switchByte and delayByte will both be 0.

thanks for the suggestions. I simply put a while loop and it works:

currentMillis = millis();
stopTime = currentMillis + delayTime1;
while(currentMillis < stopTime){
currentMillis = millis();
displayTemperature();
}

stopTime = currentMillis + delayTime1;

Adding time like this is not advised.

startTime = millis();
while(millis() - startTime < delayTime1)
{
}

Subtraction is guaranteed to work even when millis() rolls over. Addition is not.