mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Merge branch 'v2_develop' into copilot/move-fakedriver-to-terminal-drivers
This commit is contained in:
@@ -55,7 +55,13 @@ public class TimedEvents : ITimedEvents
|
|||||||
{
|
{
|
||||||
// Convert Stopwatch ticks to TimeSpan ticks (100-nanosecond units)
|
// Convert Stopwatch ticks to TimeSpan ticks (100-nanosecond units)
|
||||||
// Stopwatch.Frequency gives ticks per second, so we need to scale appropriately
|
// Stopwatch.Frequency gives ticks per second, so we need to scale appropriately
|
||||||
return Stopwatch.GetTimestamp () * TimeSpan.TicksPerSecond / Stopwatch.Frequency;
|
// To avoid overflow, we perform the operation in double precision first and then cast to long.
|
||||||
|
var ticks = (long)((double)Stopwatch.GetTimestamp () * TimeSpan.TicksPerSecond / Stopwatch.Frequency);
|
||||||
|
|
||||||
|
// Ensure ticks is positive and not overflowed (very unlikely now)
|
||||||
|
Debug.Assert (ticks > 0);
|
||||||
|
|
||||||
|
return ticks;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|||||||
@@ -92,9 +92,12 @@ public class TimedEventsTests
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Assert.True (timedEvents.Timeouts.Keys [0] > 0);
|
||||||
|
|
||||||
// Should execute on first RunTimers call
|
// Should execute on first RunTimers call
|
||||||
timedEvents.RunTimers ();
|
timedEvents.RunTimers ();
|
||||||
|
|
||||||
|
Assert.Empty (timedEvents.Timeouts);
|
||||||
Assert.True (executed);
|
Assert.True (executed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user