Skip to content

AnimationTimer ​

Namespace: Hex1b.Animation

Assembly: Hex1b.dll

Manages one-shot animation timers for triggering widget redraws.

csharp
public sealed class AnimationTimer

Inheritance ​

Object → AnimationTimer

Constructors ​

AnimationTimer() ​

Creates an AnimationTimer with the default minimum interval (16ms).

csharp
public AnimationTimer()

AnimationTimer(TimeSpan) ​

Creates an AnimationTimer with a custom minimum interval.

Parameters:

  • minimumInterval (TimeSpan): The minimum interval between frames. Values below 1ms are clamped to 1ms.
csharp
public AnimationTimer(TimeSpan minimumInterval)

Properties ​

HasScheduledTimers ​

Gets whether any timers are currently scheduled.

Returns: Boolean

csharp
public bool HasScheduledTimers { get; }

MinimumInterval ​

Gets the minimum interval between frames for this timer.

Returns: TimeSpan

csharp
public TimeSpan MinimumInterval { get; }

Methods ​

Clear() ​

Clears all scheduled timers without firing them.

csharp
public void Clear()

FireDue() ​

Fires all timers that are due and removes them from the queue.

Returns: Int32

The number of timers that were fired.

csharp
public int FireDue()

GetTimeUntilNextDue() ​

Gets the time until the next timer is due, or null if no timers are scheduled.

Returns: Nullable<TimeSpan>

TimeSpan until next timer, or null if no timers. Returns TimeSpan.Zero if a timer is already due.

csharp
public TimeSpan? GetTimeUntilNextDue()

Schedule(TimeSpan, Action) ​

Schedules a one-shot timer that fires after the specified delay.

Parameters:

  • delay (TimeSpan): The delay before firing. Clamped to minimum interval.
  • callback (Action): The callback to invoke when the timer fires.
csharp
public void Schedule(TimeSpan delay, Action callback)

Fields ​

AbsoluteMinimumInterval ​

Absolute minimum interval (1ms) to prevent CPU spin.

Returns: TimeSpan

csharp
public static readonly TimeSpan AbsoluteMinimumInterval

DefaultMinimumInterval ​

Default minimum interval between frames (16ms = ~60 FPS).

Returns: TimeSpan

csharp
public static readonly TimeSpan DefaultMinimumInterval

Remarks ​

AnimationTimer maintains a list of scheduled callbacks and provides integration with the Hex1bApp run loop. Timers are one-shot - they fire once and are removed.

A minimum interval is enforced to prevent CPU spin from overly aggressive animation requests. The default is 16ms (~60 FPS) but can be configured via .

Released under the MIT License.