kaven-basic - v6.2.0
    Preparing search index...

    Class Timer

    Represents a timer that can be used to schedule recurring tasks with a specified time interval.

    Index
    • Constructs a Timer object with the specified time interval.

      Parameters

      • interval: TimeSpan

        The time interval for the timer.

      Returns Timer

    elapsed: KavenLiteEvent<number, Timer> = ...

    Event that is triggered on each elapsed interval of the timer.

    index: number = 0

    Index representing the number of times the timer has elapsed.

    interval: TimeSpan

    The time interval between each execution of the timer.

    InvokeImmediately: boolean = false

    Controls whether the elapsed event is invoked once immediately when Start or Restart is called.

    When false (the default), the first invocation occurs after one full interval. When true, the first invocation occurs immediately and is included in Invocations; subsequent invocations use the configured interval. The ScheduleNextBeforeTrigger setting determines whether the next invocation is scheduled before or after this immediate invocation finishes.

    isRunning: boolean = false

    Indicates whether the timer has been started and has not been stopped.

    lastInvocationDateTime?: DateTime
    ScheduleNextBeforeTrigger: boolean = false

    Controls whether the next invocation is scheduled before or after the current elapsed event finishes.

    When false (the default), the timer waits for all synchronous and asynchronous elapsed handlers to finish before scheduling the next invocation. The interval therefore begins after the handlers complete, which prevents invocations from overlapping.

    When true, the next invocation is scheduled before the elapsed handlers run. This keeps invocations closer to the configured interval, but handlers can overlap if they take longer than the interval.

    startDateTime?: DateTime
    timeoutID?: string | number | Timeout

    Identifier of the currently scheduled timeout.

    • get Interval(): TimeSpan

      Gets the time interval of the timer.

      Returns TimeSpan

    • set Interval(value: TimeSpan): void

      Sets the time interval of the timer.

      Parameters

      Returns void

    • get Invocations(): number

      Gets the number of times the timer has been invoked. This property reflects the total count of elapsed intervals, indicating how many times the timer's 'Elapsed' event has been triggered.

      Returns number

    • get IsRunning(): boolean

      Gets a value indicating whether the timer is currently running.

      Returns boolean

    • get LastInvocationDateTime(): DateTime | undefined

      Gets the date and time when the timer was last invoked.

      Returns DateTime | undefined

    • get NextInvocationDateTime(): DateTime | undefined

      Gets the date and time when the next timer event is scheduled to occur.

      Returns DateTime | undefined

    • get StartDateTime(): DateTime | undefined

      Gets the date and time when the timer was started.

      Returns DateTime | undefined

    • Resets the index to zero.

      Returns void

    • Restarts the timer by stopping it, resetting the index, and then starting it again.

      Returns void

    • Starts the timer.

      Returns void

      Error if the timer is already running.

    • Stops the timer.

      Returns void

    • Triggers the elapsed event and increments the index.

      Returns Promise<number>

      A promise that resolves with the current index.

    • Schedules the next timer event based on the timer's properties.

      Parameters

      • timer: Timer

        The timer instance.

      Returns void