I have a hosted background service in ASP.NET Core, and it coexists with a bunch of web controller APIs.
The background service is registered as a hosted service:
services.AddHostedService<SampleHostedService>();
My front end will poll the web controller APIs at a rate of every 1 second. However, I noticed if I put breakpoints inside the hosted service and step through it in Visual Studio. The web controller APIs no longer respond to the regular poll of front end in a timely manner.
Is there a way to separate the web controller APIs and hosted background service? So that when I debug and step through the background service, the web controller APIs will still respond in a timely manner?
-
1I guess you'd need to have the service running in a different process to do thatTenatus– Tenatus2025年06月03日 14:30:10 +00:00Commented Jun 3 at 14:30
-
Thanks, within Asp.Net Core, if I want to run the background service in a different proces, is there any built in technology with Asp.Net core to support it?Shijie Zhang– Shijie Zhang2025年06月03日 14:38:30 +00:00Commented Jun 3 at 14:38
-
1I don't think so, you'd have to pick/create some kind of RPC systemTenatus– Tenatus2025年06月03日 15:15:56 +00:00Commented Jun 3 at 15:15