I'm working in an application with frontend Angular 6 and backend .net core 2.
I want that, if there is a certain circumstance, a procedure stored in the database (MySQL) is executed, which takes a few minutes to execute regardless of what the user continues to do. I do not need to collect any results from that procedure.
How do I launch it that way, to continue running regardless of what the user does, even if he closes the browser?
I have tried several ways ...
[HttpGet]
[Route("Check/{idCheck}")]
public async Task ComprobarDatos(int idCheck)
{
try
{
int? timeout = _context.Database.GetCommandTimeout();
_context.Database.SetCommandTimeout(600);
await _context.Database.ExecuteSqlCommandAsync("call CheckProcess({0});", idCheck)
.ConfigureAwait(false);
if(timeout!= null && timeout > 0)
{
_context.Database.SetCommandTimeout(timeout);
}
}
catch (Exception ex)
{
_logger.LogError("Ocurrió un problema ejecutando el procedimiento CheckProcesscon id {0}: " + ex.Message, idCheck);
}
}
I have also tried:
public IActionResult ...
...
_context.Database.ExecuteSqlCommand("call CheckProcess({0});", idCheck);
return Ok();
And:
public IActionResult ...
...
_context.Database.ExecuteSqlCommandAsync("call CheckProcess({0});", idCheck)
.ConfigureAwait(false);
return Ok();
And:
public IActionResult ...
...
_context.Database.ExecuteSqlCommandAsync("call CheckProcess({0});", idCheck)
.ConfigureAwait(true);
return Ok();
And it always waits for the stored procedure to finish in order to continue the execution of the code.
Thank you!