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.
public sealed class UiTimer : IDisposable
Constructors
UiTimer(uint periodMs, Action callback)
public UiTimer(uint periodMs, Action callback)
Create a periodic timer that fires callback on the UI thread.
| Parameter | Type | Description |
|---|---|---|
periodMs | uint | Period in milliseconds between callbacks. |
callback | Action | Delegate to invoke on each tick; runs on LVGL's event thread so widget updates are safe. |
UiTimer(TimeSpan period, Action callback)
public UiTimer(TimeSpan period, Action callback)
Create a periodic timer with a System.TimeSpan period (clamped to at least 1 ms).
| Parameter | Type | Description |
|---|---|---|
period | TimeSpan | Period between callbacks. |
callback | Action | Delegate to invoke on each tick; runs on the UI thread. |
Methods
Dispose()
public void Dispose()
Cancel the timer and release its pinned callback. Idempotent.
SetPeriod(TimeSpan period)
public void SetPeriod(TimeSpan period)
Change the timer period (clamped to at least 1 ms). Safe to call from any thread.
| Parameter | Type | Description |
|---|---|---|
period | TimeSpan | New period. |
SetPeriod(uint periodMs)
public void SetPeriod(uint periodMs)
Change the timer period in milliseconds. Safe to call from any thread.
| Parameter | Type | Description |
|---|---|---|
periodMs | uint | New period in milliseconds. |