I have to generate a report based on user input. The problem is this process might take long time (hours), so the only choice is to run it in background where the user can review/download the result later.
The task should be triggered by the user where he should enter the parameters to generate the report, so using the scheduled task does not help.
I tried to execute the process within an action like using Task like follows:
[HttpPost]
public IActionResult Generate(ReportModel report)
{
try
{
Task.Run(() =>
{
_reportingService.Generate(report)
});
SuccessNotification(string.Format("Generating report has been started."));
}
catch (Exception xp)
{
ErrorNotification(xp);
}
return Generate();
}
But without success, I received this error:
The operation cannot be completed because the DbContext has been disposed.
Any ideas regarding implement this issue in nopCommerce 4.0?
Best,