logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Interface ITimerService

    Interface representing a timer service for managing multiple timers.

    Namespace: Serenity.Timer.Application.Interfaces
    Assembly: Serenity.Timer.Application.dll
    Syntax
    public interface ITimerService : IService, IFoundationSettings

    Methods

    AddTimer(string, ITimer, TimeMode, bool)

    Adds an existing timer with the specified ID.

    Declaration
    void AddTimer(string id, ITimer timer, TimeMode mode = 1, bool overwrite = false)
    Parameters
    Type Name Description
    string id

    The unique identifier for the timer.

    ITimer timer

    The ITimer instance to add.

    TimeMode mode

    The time-scaling mode for the timer (default: Unscaled).

    bool overwrite

    If true, overwrites an existing timer with the same ID.

    AddTimer(string, TimeMode, bool)

    Adds a new timer with the specified ID.

    Declaration
    ITimer AddTimer(string id, TimeMode mode = 1, bool overwrite = false)
    Parameters
    Type Name Description
    string id

    The unique identifier for the new timer.

    TimeMode mode

    The time-scaling mode for the timer (default: Unscaled).

    bool overwrite

    If true, overwrites an existing timer with the same ID.

    Returns
    Type Description
    ITimer

    The newly added ITimer instance.

    GetAllTimers()

    Gets all timers managed by the service.

    Declaration
    Dictionary<string, ITimer> GetAllTimers()
    Returns
    Type Description
    Dictionary<string, ITimer>

    A dictionary of all timers, keyed by their unique identifiers.

    GetTimer(string)

    Gets a timer by its ID.

    Declaration
    ITimer GetTimer(string id)
    Parameters
    Type Name Description
    string id

    The unique identifier of the timer.

    Returns
    Type Description
    ITimer

    The ITimer instance if found; otherwise, null.

    GetTimerFormatter()

    Gets the timer formatter service.

    Declaration
    TimerFormatterService GetTimerFormatter()
    Returns
    Type Description
    TimerFormatterService

    InitializeService(TimerFactory, ILogService)

    Initializes the timer service with the specified timer factory.

    Declaration
    void InitializeService(TimerFactory timerFactory, ILogService logService)
    Parameters
    Type Name Description
    TimerFactory timerFactory

    The factory used to create timer instances.

    ILogService logService

    The log service to be used by the timer service.

    RemoveTimer(string)

    Declaration
    void RemoveTimer(string id)
    Parameters
    Type Name Description
    string id

    UpdateTimers()

    Updates all registered timers for the current frame.
    The service reads the delta from its injected ITimeProvider; callers do not pass a delta value.

    Declaration
    void UpdateTimers()
    In this article
    © 2026 Serenity. All Rights Reserved