-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Add .NET 11 breaking change documentation for Environment.TickCount/TickCount64 #50921
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| --- | ||
| title: Breaking changes in .NET 11 | ||
| titleSuffix: "" | ||
| description: Navigate to the breaking changes in .NET 11. | ||
| ms.date: 01/07/2026 | ||
| ai-usage: ai-assisted | ||
| --- | ||
| # Breaking changes in .NET 11 | ||
|
|
||
| If you're migrating an app to .NET 11, the breaking changes listed here might affect you. Changes are grouped by technology area, such as ASP.NET Core or Windows Forms. | ||
|
|
||
| [!INCLUDE [binary-source-behavioral](includes/binary-source-behavioral.md)] | ||
|
|
||
| > [!NOTE] | ||
| > This article is a work in progress. It's not a complete list of breaking changes in .NET 11. | ||
|
|
||
| ## Core .NET libraries | ||
|
|
||
| | Title | Type of change | | ||
| |-------------------------------------------------------------------|-------------------| | ||
| | [Environment.TickCount made consistent with Windows timeout behavior](core-libraries/11/environment-tickcount-windows-behavior.md) | Behavioral change | |
56 changes: 56 additions & 0 deletions
56
.../core/compatibility/core-libraries/11/environment-tickcount-windows-behavior.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| --- | ||
| title: "Breaking change - Environment.TickCount made consistent with Windows timeout behavior" | ||
| description: "Learn about the breaking change in .NET 11 where Environment.TickCount and Environment.TickCount64 on Windows now exclude sleep and hibernation time, consistent with OS wait APIs." | ||
| ms.date: 01/07/2026 | ||
| ai-usage: ai-assisted | ||
| ms.custom: https://github.com/dotnet/docs/issues/50755 | ||
| --- | ||
|
|
||
| # Environment.TickCount made consistent with Windows timeout behavior | ||
|
|
||
| On Windows, <xref:System.Environment.TickCount?displayProperty=nameWithType> and <xref:System.Environment.TickCount64?displayProperty=nameWithType> have been updated to be consistent with the behavior seen in the underlying wait APIs for the OS. They no longer include sleep or hibernation time as part of the elapsed time measured. This change also makes Windows behavior consistent with the behavior seen on other platforms and ensures it updates at the same frequency as the underlying interrupt timer for the system. This change allows for higher responsiveness in apps that opted in to higher frequency updates. | ||
|
|
||
| ## Version introduced | ||
|
|
||
| .NET 11 Preview 1 | ||
|
|
||
| ## Previous behavior | ||
|
|
||
| Previously, on Windows, `Environment.TickCount64` returned the result of the Win32 [GetTickCount64](/windows/win32/api/sysinfoapi/nf-sysinfoapi-gettickcount64) API, which updated at a fixed cadence of 10-16ms (typically 15.5ms) and included the time the system spent in sleep, hibernation, or other low-power states. | ||
|
|
||
| On other platforms (such as Linux and macOS), `Environment.TickCount64` updated at the same frequency as the underlying interrupt timer for the system and only included the time the system was considered "awake". | ||
|
|
||
| On all platforms, `Environment.TickCount` returned the truncated result of `Environment.TickCount64` and exhibited identical behavior, but was subject to overflow approximately every 49 days. | ||
|
|
||
| ## New behavior | ||
|
|
||
| On Windows, `Environment.TickCount64` now returns the result of the Win32 [QueryUnbiasedInterruptTime](/windows/win32/api/realtimeapiset/nf-realtimeapiset-queryunbiasedinterrupttime) API. This change brings the .NET API inline with the behavior used in the underlying wait APIs for the OS. It no longer includes non-awake time and updates at the same frequency as the underlying interrupt timer for the system. | ||
|
|
||
| On other platforms, `Environment.TickCount64` retains its behavior, which is consistent with the new behavior on Windows. | ||
|
|
||
| On all platforms, `Environment.TickCount` maintains its implementation and mirrors the behavior of `Environment.TickCount64`. | ||
|
|
||
| ## Type of breaking change | ||
|
|
||
| This change is a [behavioral change](../../categories.md#behavioral-change). | ||
|
|
||
| ## Reason for change | ||
|
|
||
| Windows took a similar behavior breaking change in Windows 8 and Windows Server 2012 and newer versions such that APIs that accept a timeout (like [SleepEx](/windows/win32/api/synchapi/nf-synchapi-sleepex) and [WaitForMultipleObjectsEx](/windows/win32/api/synchapi/nf-synchapi-waitformultipleobjectsex)) no longer factor in non-awake time. This caused an inconsistency with .NET, as such wait APIs are frequently used in conjunction with <xref:System.Environment.TickCount64?displayProperty=nameWithType>, leading to hard-to-diagnose bugs such as timers firing unexpectedly. | ||
|
|
||
| Additionally, the underlying API that was used, [GetTickCount64](/windows/win32/api/sysinfoapi/nf-sysinfoapi-gettickcount64), was less precise and only updated at a fixed resolution. This resolution wasn't adjusted if the underlying interrupt timer for the OS had its frequency changed, which could lead to additional work being done for apps that had opted to run at a higher priority. The behavior was also inconsistent with the behavior seen on other platforms such as macOS and Linux. | ||
|
|
||
| The change ensures consistency with the underlying OS and across platforms. It can also lead to higher responsiveness in apps that opted into more frequent updates. | ||
|
|
||
| ## Recommended action | ||
|
|
||
| Unless opted into higher frequency interrupt times, most code shouldn't experience any change in behavior. Apps will continue seeing updates at the same frequency as before. However, if update frequency is relevant, ensure that your timeouts pass in a correct value that meets the expectations of your code, or ensure that the application isn't opting into too high an update frequency. (This can only be done via P/Invoke APIs today.) | ||
|
|
||
| Some code might see timers no longer fire immediately after a machine wakes from a sleeping or low-power state. If such time is relevant, use APIs such as <xref:System.DateTime.UtcNow?displayProperty=nameWithType> to ensure such time can always be included. Such code might have to account for potential clock adjustments. | ||
|
|
||
| Code that is impacted by this change on Windows is likely already impacted by the same scenario on other platforms such as Linux and macOS. | ||
|
|
||
| ## Affected APIs | ||
|
|
||
| - <xref:System.Environment.TickCount?displayProperty=fullName> | ||
| - <xref:System.Environment.TickCount64?displayProperty=fullName> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The title should use a colon instead of a hyphen after "Breaking change" to maintain consistency with other .NET 10 breaking change articles. Change "Breaking change -" to "Breaking change:".