Statistiques
| Branche: | Révision:

root / GES_PAC / ViewModel / TimerPublisher.cs @ 9601eaf0

Historique | Voir | Annoter | Télécharger (661 octets)

1
namespace GES_PAC.ViewModel
2
{
3
    public class TimerPublisher
4
    {
5
        private readonly IDispatcherTimer _timer;
6
        public event EventHandler? Tick;
7

    
8
        public TimerPublisher()
9
        {
10
            _timer = Dispatcher.GetForCurrentThread().CreateTimer();
11
            _timer.Interval = TimeSpan.FromSeconds(15);
12
            _timer.Tick += (s, e) => Tick?.Invoke(this, EventArgs.Empty);
13
        }
14

    
15
        public void Start() => _timer.Start();
16
        public void Stop() => _timer.Stop();
17

    
18
        public void Register(EventHandler handler) => Tick += handler;
19
        public void Unregister(EventHandler handler) => Tick -= handler;
20
    }
21

    
22
}