Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixes Timer crash due to negative inputs. #1985

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

kamronbatman
Copy link
Contributor

@kamronbatman kamronbatman commented Oct 28, 2024

Summary

Fixes a few minor issues with timers:

  • Timer.Delay and Timer.Interval was not reflecting the actual tick time (aligned to the next 8ms)
  • Negative delay values were causing a crash when DateTime.Now - delay was below DateTime.MinValue
  • Timer.Next now reflects the correct wall clock tick time based on the adjusted Delay.
  • Timer.Next is not assigned when the timer is started. This was important for timers that were created, but started later.

@kamronbatman kamronbatman changed the title fix: Fixes Timer Delay/Interval & negative inputs fix: Fixes Timer crash due to negative inputs. Oct 28, 2024
@@ -214,18 +224,19 @@ private static void AddTimer(Timer timer, long delay)
}
}

timer.Next = Core.Now + timer.Delay;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that Next is now assigned when the timer is added. It no longer erroneously reflects the Next tick based on when the timer is added.

Copy link

github-actions bot commented Oct 28, 2024

Qodana for .NET

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Detected 20 dependencies

Third-party software list

This page lists the third-party software dependencies used in ModernUO

Dependency Version Licenses
Argon2.Bindings 1.16.1 MIT
BouncyCastle.Cryptography 2.4.0 MIT
CommunityToolkit.HighPerformance 8.3.2 MIT
LibDeflate.Bindings 1.0.2.120 GPL-3.0-only
MailKit 4.8.0 MIT
Microsoft.Extensions.FileSystemGlobbing 8.0.0 MIT
MimeKit 4.8.0 MIT
ModernUO.CodeGeneratedEvents.Annotations 1.0.0 GPL-3.0-only
ModernUO.CodeGeneratedEvents.Generator 1.0.3.2 GPL-3.0-only
ModernUO.Serialization.Annotations 2.9.1 GPL-3.0-only
ModernUO.Serialization.Generator 2.11.3 GPL-3.0-only
Nerdbank.GitVersioning 3.6.143 MIT
PollGroup 1.5.1 BSD-3-Clause
Serilog.Sinks.Async 2.0.0 Apache-2.0
Serilog.Sinks.Console 6.0.0 Apache-2.0
Serilog 4.0.2 Apache-2.0
System.Formats.Asn1 8.0.1 MIT
System.IO.Hashing 8.0.0 MIT
System.Security.Cryptography.Pkcs 8.0.0 MIT
Zstd.Binaries 1.6.0 MIT
Contact Qodana team

Contact us at [email protected]

@kamronbatman kamronbatman merged commit cc6d029 into main Oct 29, 2024
13 checks passed
@kamronbatman kamronbatman deleted the kbatman/fix_timer_next branch October 29, 2024 00:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant