Represents a high-resolution timer that can trigger events at specified intervals and supports various timer types and cycles. This class is designed to be used within the Gondwana engine.
More...
|
| static Timer | Add (string timerID, TimerType type, TimerCycles cycles, double length) |
| | Creates a new timer with the specified parameters and adds it to the collection of active timers.
|
| static Timer | Add (TimerType type, TimerCycles cycles, double length) |
| | Creates and adds a new timer with the specified type, cycle count, and duration.
|
| static void | Remove (string timerID) |
| | Removes the timer associated with the specified timer ID and releases its resources.
|
| static Timer | Get (string timerID) |
| | Retrieves the Timer instance associated with the specified timer ID.
|
| static void | ClearAll () |
| | Removes and disposes all active timers, clearing the entire timer collection.
|
|
| TimerType | Type [get] |
| | Gets the type of the timer, indicating whether it is a pre-cycle or post-cycle timer.
|
| TimerCycles | Cycles [get] |
| | Gets the current timer cycles, representing whether the timer is set to run once or repeatedly.
|
| long | Length [get] |
| | Gets the length of the current timer interval in seconds.
|
| string | TimerID = string.Empty [get, set] |
| | Gets the unique identifier for the Timer.
|
| bool | Paused [get, set] |
| | Gets or sets a value indicating whether the Timer is currently paused.
|
| static bool | PausedAll [get, set] |
| | Gets or sets a value indicating whether all operations are globally paused.
|
| static int | Count [get] |
| | Gets the total number of active timers.
|
| static string[] | TimerIDs [get] |
| | Gets an array of timer identifiers currently managed by the Engine.
|
Represents a high-resolution timer that can trigger events at specified intervals and supports various timer types and cycles. This class is designed to be used within the Gondwana engine.
The Timer class provides functionality for creating and managing timers that can trigger events based on a specified duration and cycle type. Timers can be paused, resumed, and disposed of when no longer needed. The class also supports managing multiple timers through static methods, such as adding, removing, and retrieving timers by their unique identifiers. This class is thread-safe for managing timers but does not guarantee thread safety for individual timer instances. Use appropriate synchronization if accessing instance members from multiple threads.
| void Gondwana.Timers.Timer.ClearAll |
( |
| ) |
|
|
static |
Removes and disposes all active timers, clearing the entire timer collection.
This method iterates through all active timers, disposes each one, and removes it from the internal collection. After calling this method, the timer collection will be empty and all previously active timers will no longer raise events.
This method is typically called during engine shutdown or when resetting the engine state. It ensures proper cleanup of all timer resources and event subscriptions.
This method is thread-safe and can be called from any thread.
| void Gondwana.Timers.Timer.Dispose |
( |
| ) |
|
Releases all resources used by the Timer and removes it from the collection of active timers.
This method performs cleanup of the timer instance, including:
-
Removing the timer from the internal collection of active timers
-
Clearing all event subscribers from the Tick event
-
Marking the timer as disposed to prevent further use
After disposal, the timer will no longer raise Tick events and cannot be reused. Calling Dispose multiple times is safe and will have no effect after the first call.
This method suppresses finalization to prevent the finalizer from running, as cleanup has already been performed.