using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Timers; namespace BlaServApp.UI.Services { /// /// Timer a consumo /// https://wellsb.com/csharp/aspnet/blazor-timer-navigate-programmatically/ /// (da verificare) /// public class BlazorTimer { #region Private Fields private Timer _timer; #endregion Private Fields #region Public Events public event Action OnElapsed; #endregion Public Events #region Private Methods private void NotifyTimerElapsed(Object source, ElapsedEventArgs e) { OnElapsed?.Invoke(); _timer.Dispose(); } #endregion Private Methods #region Public Methods public void SetTimer(double interval) { _timer = new Timer(interval); _timer.Elapsed += NotifyTimerElapsed; _timer.Enabled = true; } #endregion Public Methods } }