Files
maui-linux/Hosting/LinuxDispatcherTimer.cs
Dave Friedel 1f096c38dc Update with recovered code from VM binaries (Jan 1)
Recovered from decompiled OpenMaui.Controls.Linux.dll:
- SkiaShell.cs: FlyoutHeader, FlyoutFooter, scroll support (918 -> 1325 lines)
- X11Window.cs: Cursor support (XCreateFontCursor, XDefineCursor)
- All handlers with dark mode support
- All services with latest implementations
- LinuxApplication with theme change handling
2026-01-01 06:22:48 -05:00

70 lines
1.0 KiB
C#

using System;
using System.Threading;
using Microsoft.Maui.Dispatching;
namespace Microsoft.Maui.Platform.Linux.Hosting;
internal class LinuxDispatcherTimer : IDispatcherTimer
{
private Timer? _timer;
private TimeSpan _interval = TimeSpan.FromMilliseconds(16L, 0L);
private bool _isRunning;
private bool _isRepeating = true;
public TimeSpan Interval
{
get
{
return _interval;
}
set
{
_interval = value;
}
}
public bool IsRunning => _isRunning;
public bool IsRepeating
{
get
{
return _isRepeating;
}
set
{
_isRepeating = value;
}
}
public event EventHandler? Tick;
public void Start()
{
if (!_isRunning)
{
_isRunning = true;
_timer = new Timer(OnTimerCallback, null, _interval, _isRepeating ? _interval : Timeout.InfiniteTimeSpan);
}
}
public void Stop()
{
_isRunning = false;
_timer?.Dispose();
_timer = null;
}
private void OnTimerCallback(object? state)
{
this.Tick?.Invoke(this, EventArgs.Empty);
if (!_isRepeating)
{
Stop();
}
}
}