ASP.NET Core Web API that also controls hardware devices and interacts with a database

Hello, I'm currently creating an application that controls multiple hardware devices (they run on FTDI chips), and I wanted to expose some features through a web API. The hardware part of the process needs to be running on its own, and periodically polling the hardware devices and putting data into a database. My current thought is to create a perpetual Task(endless while loop) that I call .Run() upon before the standard app.Run() in the main Program.cs file. Would this approach be suitable for being able to serve the API as well as perform background work with the hardware, or would there be a better solution? The idea is that both the API and the hardware control will be running as long as the PC is on. Thank you in advance!

Looking for more? Join the community!