Skip to main content

UiTimer Class

Package: GHIElectronics.Endpoint.UI
Namespace: GHIElectronics.Endpoint.UI

Thread-safe periodic callback that runs on the UI thread. The callback fires inside UI.Run's LVGL pump every periodMs milliseconds, so widget updates in it are safe (LVGL itself is single- threaded). Dispose cancels the timer. Create / SetPeriod / Dispose are safe from any thread; the body runs on the UI thread.

class UiTimer(IDisposable): ...

Constructors​

UiTimer(uint periodMs, Action callback)​

def __init__(self, periodMs: int, callback: Action):

Create a periodic timer that fires callback on the UI thread.

ParameterTypeDescription
periodMsuintPeriod in milliseconds between callbacks.
callbackActionDelegate to invoke on each tick; runs on LVGL's event thread so widget updates are safe.

UiTimer(TimeSpan period, Action callback)​

def __init__(self, period: datetime.timedelta, callback: Action):

Create a periodic timer with a System.TimeSpan period (clamped to at least 1 ms).

ParameterTypeDescription
periodTimeSpanPeriod between callbacks.
callbackActionDelegate to invoke on each tick; runs on the UI thread.

Methods​

Dispose()​

def Dispose(self) -> None:

Cancel the timer and release its pinned callback. Idempotent.

SetPeriod(TimeSpan period)​

def SetPeriod(self, period: datetime.timedelta) -> None:

Change the timer period (clamped to at least 1 ms). Safe to call from any thread.

ParameterTypeDescription
periodTimeSpanNew period.

SetPeriod(uint periodMs)​

def SetPeriod(self, periodMs: int) -> None:

Change the timer period in milliseconds. Safe to call from any thread.

ParameterTypeDescription
periodMsuintNew period in milliseconds.