i have read this article https://blog.elmah.io/async-processing-of-long-running-tasks-in-asp-net-core/
first this article simulate a long running operation like
public async Task<IActionResult> Index()
{
await CallSlowApi();
return View();
}
private async Task CallSlowApi()
{
_logger.LogInformation($"Starting at {DateTime.UtcNow.TimeOfDay}");
await Task.Delay(10000);
_logger.LogInformation($"Done at {DateTime.UtcNow.TimeOfDay}");
}
with above approach page took 10 seconds and 30 milliseconds to load but the moment does the same job by ASP.NET Core background service then page took 13 milliseconds
i like to know how load reduce to 13 milliseconds ?
what these two line of code is doing ?
services.AddHostedService<LongRunningService>();
services.AddSingleton<BackgroundWorkerQueue>();
please some one help me to understand.
Thanks