Why does sending values threw Serial Monitor halts process

I have a really simple sketch, just a blinking light. When I type a number in the serial monitor then that becomes the new interval. However, if I change from 30 to 100ms for example then first there is a second where the light does nothing anymore. Why the halt? And how can I prevent this?

My goal is to make a node for blender (the 3d application). I kind of got this working but the huge halt is a real problem when the timeline runs at 30 frames a second for example.

int the_delay = 300;

void setup() {
  Serial.begin(115200);
  pinMode(12, OUTPUT);
}

void loop() {
  digitalWrite(12, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(the_delay);              // wait for a second
  digitalWrite(12, LOW);    // turn the LED off by making the voltage LOW
  delay(the_delay);              // wait for a second
}


void serialEvent() {
  
  while (Serial.available()) {   
    the_delay = Serial.parseInt();
    Serial.println(the_delay);
  }
}

if instead of while.

Thanks, but it didn't have any influence.

Get rid of the delays altogether.

You'll get a delay with this as well as your own delay() calls: Serial.parseInt(); It waits for a timeout to be sure no more digits are coming. See https://www.arduino.cc/en/Serial/SetTimeout. The documentation for serialEvent() explicitly warns about delay() calls in the loop(). See https://www.arduino.cc/en/Tutorial/SerialEvent

All thanks, I should be able to continue!