Blazor setTimeout
If you need something like JavaScript's setTimeout in Blazor, you can achieve the same thing with a System.Threading.Timer:
The time sponsored by Accurist is @Time
private string Time { get; set; }
protected override void OnInit()
{
var timer = new System.Threading.Timer((_) => {
Time = DateTime.UtcNow.ToString();
InvokeAsync(StateHasChanged);
}, null, 0, 1000);
base.OnInit();
}
Comments