You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Timers can't wake up at "exactly" the time listed (this is a hardware/OS problem, not a .NET problem). Your application is waking up early, possibly in part due to float precision issues or just the date/time math, and then reschedules itself because it was slightly early. There can also be "spurious wakes", where threads or tasks get scheduled erroneously even without timer expiration (although those will mostly be handled for you at this level).
If you need real scheduling support in an application, there are multiple libraries that can handle this for you; otherwise you will need to account for this yourself.
Scheduling is generally a hard problem. For instance,
private static DateTime GetNextMidnight()
... Due to DST or other timezones shenaniganry, not all days start at midnight (or may have midnight twice).
Description
I have a timer that executes every midnight and this issue only occurs on a Mac mini 4.
The code snippet will run run at 23:59:59 and @ 00:00:00
Reproduction Steps
`using System.Timers;
namespace timerTest
{
internal class Program
{
static System.Timers.Timer? timer;
}
`
Expected behavior
Timer should execute once.
Actual behavior
Timer runs twice.
Timer triggered @ 2025-03-01 11:59:59 PM
Timer triggered @ 2025-03-02 12:00:00 AM
Regression?
I don;t know.
Known Workarounds
Didnt try working on workarounds.
Configuration
.NET SDK:
Version: 9.0.200
Commit: 90e8b202f2
Workload version: 9.0.200-manifests.69179adf
MSBuild version: 17.13.8+cbc39bea8
Runtime Environment:
OS Name: Mac OS X
OS Version: 15.3
OS Platform: Darwin
RID: osx-arm64
Base Path: /usr/local/share/dotnet/sdk/9.0.200/
.NET workloads installed:
[wasm-tools]
Installation Source: SDK 9.0.200
Manifest Version: 9.0.2/9.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/9.0.100/microsoft.net.workload.mono.toolchain.current/9.0.2/WorkloadManifest.json
Install Type: FileBased
[macos]
Installation Source: SDK 9.0.200
Manifest Version: 15.2.9180/9.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/9.0.100/microsoft.net.sdk.macos/15.2.9180/WorkloadManifest.json
Install Type: FileBased
[ios]
Installation Source: SDK 9.0.200
Manifest Version: 18.2.9180/9.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/9.0.100/microsoft.net.sdk.ios/18.2.9180/WorkloadManifest.json
Install Type: FileBased
[maccatalyst]
Installation Source: SDK 9.0.200
Manifest Version: 18.2.9180/9.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/9.0.100/microsoft.net.sdk.maccatalyst/18.2.9180/WorkloadManifest.json
Install Type: FileBased
[maui]
Installation Source: SDK 9.0.200
Manifest Version: 9.0.14/9.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/9.0.100/microsoft.net.sdk.maui/9.0.14/WorkloadManifest.json
Install Type: FileBased
[android]
Installation Source: SDK 9.0.200
Manifest Version: 35.0.39/9.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/9.0.100/microsoft.net.sdk.android/35.0.39/WorkloadManifest.json
Install Type: FileBased
Configured to use loose manifests when installing new manifests.
Host:
Version: 9.0.2
Architecture: arm64
Commit: 80aa709
.NET SDKs installed:
9.0.101 [/usr/local/share/dotnet/sdk]
9.0.102 [/usr/local/share/dotnet/sdk]
9.0.200 [/usr/local/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 9.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 9.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Other architectures found:
None
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Other information
No response
The text was updated successfully, but these errors were encountered: