53 lines
1.3 KiB
C#
53 lines
1.3 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace MP.MON.Components.Compo
|
|
{
|
|
public partial class CmpHeader : ComponentBase, IDisposable
|
|
{
|
|
#region Public Methods
|
|
|
|
public void Dispose()
|
|
{
|
|
aTimer.Stop();
|
|
aTimer.Dispose();
|
|
}
|
|
|
|
public void ElapsedTimer(Object source, System.Timers.ElapsedEventArgs e)
|
|
{
|
|
var pUpd = Task.Run(async () =>
|
|
{
|
|
await Task.Delay(1);
|
|
//Console.WriteLine($"{DateTime.Now} | Elapsed Timer Footer");
|
|
await InvokeAsync(() => StateHasChanged());
|
|
});
|
|
pUpd.Wait();
|
|
}
|
|
|
|
public void StartTimer()
|
|
{
|
|
int tOutPeriod = 1000;
|
|
aTimer = new System.Timers.Timer(tOutPeriod);
|
|
aTimer.Elapsed += ElapsedTimer;
|
|
aTimer.Enabled = true;
|
|
aTimer.Start();
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Methods
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
StartTimer();
|
|
Console.WriteLine($"OnInitialized Header completato");
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private static System.Timers.Timer aTimer = null!;
|
|
|
|
#endregion Private Fields
|
|
}
|
|
} |