fix: Fixes timers detaching if they are stopped/started in OnTick (#1906)

This commit is contained in:
Kamron Batman 2024-08-05 22:00:48 -07:00 committed by GitHub
parent 6a476e6254
commit 2c9b3ef112
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -139,14 +139,15 @@ public partial class Timer
var prof = timer.GetProfile();
prof?.Start();
var version = timer.Version;
// Stop the timer from running so that way if Start() is called in OnTick, the timer will be started.
if (finished)
{
timer.InternalStop();
timer.Version++;
}
var version = timer.Version;
timer.OnTick();
prof?.Finish();
@ -160,7 +161,6 @@ public partial class Timer
{
// Already stopped and detached, now run OnDetach
timer.OnDetach();
timer.Version++;
return;
}