In Asp.Net Core controller I'd like to do something like below:
// Start preparing a report as string:
string reportText = await ReportService.PrepareAsync();
// wait for 10 seconds; how?
if (secondsPassed > 10)
{
// When finished, save the report text to database,
// and notify a user by SignalR
}
else
{
// Report finished within 10 seconds;
// return immediately as a json response
return Ok(new { Report = reportText });
}
What is the recommended way of doing the above or similar task?