Added a Toolkit.WinUI project

This commit is contained in:
Dan Clark
2024-11-02 21:21:09 +00:00
parent 7a4a299262
commit 4efde5bdd7
4 changed files with 86 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
using Toolkit.Foundation;
namespace Toolkit.WinUI;
public class DispatcherTimer :
IDispatcherTimer
{
private readonly System.Windows.Threading.DispatcherTimer timer;
private readonly Action actionDelegate;
public DispatcherTimer(Action actionDelegate, TimeSpan interval)
{
timer = new System.Windows.Threading.DispatcherTimer
{
Interval = interval
};
timer.Tick += OnTick;
this.actionDelegate = actionDelegate;
}
private void OnTick(object? sender, EventArgs args) =>
actionDelegate?.Invoke();
public void Start()
{
timer.Start();
}
public void Stop()
{
timer.Stop();
}
}