Files
egwcorelib/EgwCoreLib.BlazorTest/Pages/TestLoading.razor.cs
T

58 lines
1.7 KiB
C#

namespace EgwCoreLib.BlazorTest.Pages
{
public partial class TestLoading
{
#region Protected Properties
protected double expTime { get; set; } = 20;
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 = stdWait * 1000;
//nextVal = stepVal;
//currVal = 0;
for (int currStep = 1; currStep <= numSteps; currStep++)
{
//await Task.Delay(1);
// aggiorno valori
currVal = (currStep - 1) * stepVal;
nextVal = currStep * stepVal;
// se max mi fermo...
if (nextVal > maxVal)
{
nextVal = maxVal;
}
await InvokeAsync(StateHasChanged);
nextWait = (int)(rnd.Next(2000, 2500) * 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 double expTimeMSec = 10000;
private int maxVal = 100;
private int nextVal = 100;
private Random rnd = new Random();
private string titleMsg = "Test Progress";
#endregion Private Fields
}
}