mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-09-06 12:42:02 +12:00
Forms replaced with WPF Migration not complete, yet Known open points marked with TODOs Limited and non-optimized feature set
45 lines
1.1 KiB
C#
45 lines
1.1 KiB
C#
// <copyright file="WaitLeave.cs" company="PlaceholderCompany">
|
|
// Copyright (c) PlaceholderCompany. All rights reserved.
|
|
// </copyright>
|
|
|
|
namespace SystemTrayMenu.Handler
|
|
{
|
|
using System;
|
|
using System.Windows.Threading;
|
|
using SystemTrayMenu.Utilities;
|
|
|
|
internal class WaitLeave : IDisposable
|
|
{
|
|
private readonly DispatcherTimer timerLeaveCheck = new();
|
|
|
|
public WaitLeave(int timeUntilTriggered)
|
|
{
|
|
timerLeaveCheck.Interval = TimeSpan.FromMilliseconds(timeUntilTriggered);
|
|
timerLeaveCheck.Tick += TimerLeaveCheckTick;
|
|
}
|
|
|
|
public event Action LeaveTriggered;
|
|
|
|
public void Dispose()
|
|
{
|
|
timerLeaveCheck.Stop();
|
|
}
|
|
|
|
internal void Start()
|
|
{
|
|
timerLeaveCheck.Stop();
|
|
timerLeaveCheck.Start();
|
|
}
|
|
|
|
internal void Stop()
|
|
{
|
|
timerLeaveCheck.Stop();
|
|
}
|
|
|
|
internal void TimerLeaveCheckTick(object sender, EventArgs e)
|
|
{
|
|
timerLeaveCheck.Stop();
|
|
LeaveTriggered?.Invoke();
|
|
}
|
|
}
|
|
}
|