lundi 2 mars 2020

Polling thread in Blazor

I am building a Blazor application with a REST API and Web interface. I will also have a monitoring part of the application that will poll data each second from a lot of different data sources. I have created a long running thread in a separate class that simply polls the data I want and it seems to be working fine. The application template I am using is a Blazor ASP.NET Server application. Simply like this:

 m_pollThread = new Thread(new ThreadStart(PollThread))
 {
    IsBackground = true
 };
 m_pollThread.Start();

What I am wondering now is: is it completely wrong with respect to programming patterns to put this type of polling threads inside of the Blazor application itself? Is there some problems doing like this that will backfire later on (memory consumption, performance of the rest of the application)? The reason why I am asking is because as far as I know, Blazor and ASP.NET Core applications are general "on-request" and wakes up when something is requested, and not executing long-running endless polling tasks. I do not know if I could run that within IIS for instance.

Aucun commentaire:

Enregistrer un commentaire