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

Popular posts from this blog

Angular - How to create composite controls that work with formGroup/formGroupName and ReactiveForms

Convert absolute path to relative path