namespace EgwCoreLib.BlazorTest.Pages { public partial class TestLoading { #region Protected Properties protected double expTime { get; set; } = 6; protected int numSteps { get; set; } = 4; #endregion Protected Properties #region Protected Methods protected async Task StartLongTimer() { double stdWait = expTime / numSteps; int nextWait = 1000; int stepVal = maxVal / numSteps; // imposto i valori x progress.. maxVal = 100; expTimeMSec = (int)(stdWait * 1000); //nextVal = stepVal; //currVal = 0; for (int currStep = 1; currStep <= numSteps; currStep++) { // aggiorno valori currVal = (currStep - 1) * stepVal; nextVal = currStep * stepVal; // se max mi fermo... if (nextVal > maxVal) { nextVal = maxVal; } await InvokeAsync(StateHasChanged); // simulo ritardo importante (da 2 a 3 volte nextWait = (int)(rnd.Next(2000, 3000) * stdWait); // attendo step successivi... await Task.Delay(nextWait); } await Task.Delay(1); currVal = maxVal; await InvokeAsync(StateHasChanged); } #endregion Protected Methods #region Private Fields private int currVal = 100; private int expTimeMSec = 10000; private int maxVal = 100; private int nextVal = 100; private Random rnd = new Random(); private string titleMsg = "SIM Progress"; #endregion Private Fields } }