@inherits FnzComponentBase

@code {
    [Parameter, Required] public int Throttle { get; set; }
}

<div @attributes="@InputAttributes">
    @Display.NullOrEmptyEscape("Processing...")
    <div class="progress">
        <div class="progress-bar progress-bar-striped progress-bar-animated" style="width: @(Percent)%"></div>
    </div>
</div>

@code {

    private float Percent;
    private string Display;

    private DateTime _point = DateTime.Now;

    public async Task SetProgress(float ratio, string display)
    {
        Percent = ratio * 100;
        Display = display;
        if ((DateTime.Now - _point).TotalMilliseconds >= Throttle)
        {
            StateHasChanged();
            await Task.Delay(5);
            _point = DateTime.Now;
        }
    }

    public async Task ForceUpdate()
    {
        StateHasChanged();
        await Task.Delay(10);
    }

}
