diff --git a/MP.SPEC/Components/ListPARAMS.razor.cs b/MP.SPEC/Components/ListPARAMS.razor.cs index 82ae4d95..dd639ba0 100644 --- a/MP.SPEC/Components/ListPARAMS.razor.cs +++ b/MP.SPEC/Components/ListPARAMS.razor.cs @@ -2,6 +2,7 @@ using Microsoft.JSInterop; using MP.Data.DatabaseModels; using MP.SPEC.Data; +using System.Diagnostics; namespace MP.SPEC.Components { @@ -13,8 +14,6 @@ namespace MP.SPEC.Components public bool LiveUpdate { get; set; } - private bool _liveUpdate { get; set; } - [Parameter] public int MaxRecord { @@ -84,7 +83,6 @@ namespace MP.SPEC.Components public void Dispose() { - //aTimer.Elapsed -= ElapsedTimer; aTimer.Stop(); aTimer.Dispose(); } @@ -93,12 +91,22 @@ namespace MP.SPEC.Components { if (!isLoading && LiveUpdate) { + aTimer.Stop(); + // inizio misura esecuzione + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); var pUpd = Task.Run(async () => { await Task.Delay(1); await InvokeAsync(() => reloadData(true)); }); pUpd.Wait(); + // misuro tempo esecuzione + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + int deltaTime = tOutPeriod - (int)ts.TotalMilliseconds; + aTimer.Interval = deltaTime > 100 ? deltaTime : 100; + aTimer.Start(); } } @@ -116,9 +124,10 @@ namespace MP.SPEC.Components isLoading = false; } + private int tOutPeriod { get; set; } = 2000; + public void StartTimer() { - int tOutPeriod = 2000; //int.TryParse(Configuration["ReloadStatusTimer"], out tOutPeriod); aTimer = new System.Timers.Timer(tOutPeriod); aTimer.Elapsed += ElapsedTimer; @@ -175,7 +184,7 @@ namespace MP.SPEC.Components #region Private Fields private static System.Timers.Timer aTimer = null!; - private int _maxRecord = 300; + private int _maxRecord = 100; private string _selFlux = "*"; private string _selMacchina = "*"; private FluxLog? currRecord = null; diff --git a/MP.SPEC/Pages/PARAMS.razor b/MP.SPEC/Pages/PARAMS.razor index e4f75732..0630103c 100644 --- a/MP.SPEC/Pages/PARAMS.razor +++ b/MP.SPEC/Pages/PARAMS.razor @@ -61,7 +61,7 @@