I just came into a very strange issue regarding cancellationToken. The web API is developed using .Net Core and frontend is in Angular. 1 hour ago I try to develop more feature and before starting I run it again and suddenly the cancellationToken becomes true. This never happens before. I made no changes in backend and frontend.
The controller function:
[HttpDelete("dqc")]
[AllowAnonymous]
public async Task<IActionResult> DeleteDQCAsync([FromBody] IEnumerable<DqcDto> dqcs, CancellationToken cancellationToken)
{
try
{
var response = await _managerService.DeleteDqcAsync(dqcs, cancellationToken);
if (response)
{
return Ok(new { message = "DQC codes have been deleted successfully" });
}
else
{
return BadRequest(new { message = "Delete selected DQC codes failed." });
}
}
catch (Exception)
{
throw;
}
}
Even strange is, when I add breakpoint and debug the code, the function is invoked and cancellation is false. One second later the cancellationToken becomes true but I click nothing. Sometimes when I hit the button in the frontend, the function is even not invoked. Only when I add breakpoint in browser and execute line by line, the cancellationToken is always false.
Could someone gives me a hint how I can figure out why this happens?