OnTimer bug

 

There seems to be a bug with the OnTimer event.

I'm trying to restart the timer inisde the OnTimer event and the  first cycle after the restart is not executed. Let me show you an example:

void OnInit() {
   EventSetTimer(2);
}


bool timer_set = false;
void OnTimer() {
   if (!timer_set) {
      timer_set = true;
      EventKillTimer();
      EventSetTimer(10);
   }
   Print("[INFO] - OnTimer: ", TimeGMT());
}

With this code we should get the following execution:

0:00:00 - EA starts and sets the timer for every 2 seconds.

0:00:02 - EA executes timer and resets it for every 10 seconds

0:00:22 - EA executes timer

0:00:32 - EA executes timer


The EA should have executed the timer on the 0:00:12 second but it didn't.


How is this possible? Am I missunderstanding something in regards to the OnTimer event? Is this a bug?


Many thanks,

Kevin

 
Bug confirmed and reported to MQ attention.
 
Alain Verleyen #:
Bug confirmed and reported to MQ attention.
This behavior has exit d for years. - I am not sure this will be considered a bug.

After killing the timer, and again setting the timer.
If i remember right, without killing it, but only setting the timer, the sequence will be:

00:02, 00:04, 00:14
 
Dominik Egert #:
This behavior has exit d for years. - I am not sure this will be considered a bug.

After killing the timer, and again setting the timer.
If i remember right, without killing it, but only setting the timer, the sequence will be:

00:02, 00:04, 00:14
No. Killing or not the timer doesn't change anything.
 
Alain Verleyen #:
No. Killing or not the timer doesn't change anything.
Then I remember wrong, or it got "fixed".


 

Thank you all
Fixed
First timer event for timer created from OnTimer event will not be skipped

 
Kevin de la Coba Malam:

There seems to be a bug with the OnTimer event.

I'm trying to restart the timer inisde the OnTimer event and the  first cycle after the restart is not executed. Let me show you an example:

With this code we should get the following execution:

0:00:00 - EA starts and sets the timer for every 2 seconds.

0:00:02 - EA executes timer and resets it for every 10 seconds

0:00:22 - EA executes timer

0:00:32 - EA executes timer


The EA should have executed the timer on the 0:00:12 second but it didn't.


How is this possible? Am I missunderstanding something in regards to the OnTimer event? Is this a bug?


Many thanks,

Kevin

setting the timer should not be inside the function itself. This way there will never be a bug.you have a closed cyclic variable, this leads to an error