Sionex
Sionex

Reputation: 23

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

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?

Upvotes: 2

Views: 5010

Answers (1)

Henk Holterman
Henk Holterman

Reputation: 273179

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.

Upvotes: 2

Related Questions