35468be19f
- modifica alert display come componente (test a tempo...)
71 lines
1.6 KiB
C#
71 lines
1.6 KiB
C#
namespace MP.SPEC.Components
|
|
{
|
|
public partial class AskCloseOdl : IDisposable
|
|
{
|
|
#region Public Methods
|
|
|
|
public void Dispose()
|
|
{
|
|
aTimer.Elapsed -= ElapsedTimer;
|
|
aTimer.Stop();
|
|
aTimer.Dispose();
|
|
GC.Collect();
|
|
}
|
|
|
|
public void ElapsedTimer(object? source, System.Timers.ElapsedEventArgs e)
|
|
{
|
|
aTimer.Stop();
|
|
var pUpd = Task.Run(async () =>
|
|
{
|
|
await Task.Delay(1);
|
|
await InvokeAsync(() => StateHasChanged());
|
|
});
|
|
pUpd.Wait();
|
|
aTimer.Interval = RefreshPeriod;
|
|
aTimer.Start();
|
|
}
|
|
|
|
public void StartTimer()
|
|
{
|
|
aTimer = new System.Timers.Timer(RefreshPeriod);
|
|
aTimer.Elapsed += ElapsedTimer;
|
|
aTimer.Enabled = true;
|
|
aTimer.Start();
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Fields
|
|
|
|
protected int RefreshPeriod = 1000;
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Properties
|
|
|
|
protected bool showRequest
|
|
{
|
|
get
|
|
{
|
|
return DateTime.Now.Second % 10 < 7;
|
|
}
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
StartTimer();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private static System.Timers.Timer aTimer = null!;
|
|
|
|
#endregion Private Fields
|
|
}
|
|
} |