Files

60 lines
1.6 KiB
C#

using Microsoft.Extensions.Logging;
using NLog;
namespace Web3D.Pack.Components
{
public partial class CmpFooter : IDisposable
{
#region Public Methods
public void Dispose()
{
if (aTimer != null)
{
aTimer.Elapsed -= ElapsedTimer;
aTimer.Stop();
aTimer.Dispose();
}
}
public void ElapsedTimer(object? source, System.Timers.ElapsedEventArgs e)
{
var pUpd = Task.Run(async () =>
{
await Task.Delay(1);
await InvokeAsync(() => StateHasChanged());
});
pUpd.Wait();
}
public void StartTimer()
{
int tOutPeriod = 5000;
//int.TryParse(Configuration["ReloadStatusTimer"], out tOutPeriod);
aTimer = new System.Timers.Timer(tOutPeriod);
aTimer.Elapsed += ElapsedTimer;
aTimer.Enabled = true;
aTimer.Start();
}
#endregion Public Methods
#region Protected Methods
protected override void OnInitialized()
{
var rawVers = typeof(Program).Assembly.GetName().Version; ;
version = rawVers != null ? rawVers : new Version("0.0.0.0");
}
#endregion Protected Methods
#region Private Fields
private static Logger Log = LogManager.GetCurrentClassLogger();
private System.Timers.Timer aTimer = null!;
private Version version = null!;
#endregion Private Fields
}
}