How to run schedule task in c# blazor every 30 second

Viewed 1849

I am writing a blazor server side application. I have like 100 Binance API or more to work with. How can I run a scheduled task that will monitor each API on given amount of time. Or is there any better way to approach approach to this?

1 Answers

You can add a background service. Nothing to do with Blazor, just Asp.Net:

It's just one line in the Startup class:

public void ConfigureServices(IServiceCollection services)
{
   ...       
   services.AddHostedService<MyBackgroundService>();
}

and then implement your own MyBackgroundService with a loop or a Timer.

Related