does task.delay infinite code after it executed?

Just a quick question. We're having some misunderstanding here.

for simplicity some code is removed:

public async Task ConsumeAsync<T>(CancellationToken cancellationToken)
{
 _logger.LogInformation("consume async");

 await Task.Delay(Timeout.Inifite, cancellationToken);

      _logger.LogInformation("cancelled");
}

Should the last logline be logged or not when a cancel is requested?

Jon Skeet
people
quotationmark

Should the last logline be logged or not when a cancel is requested?

No, because the task returned by Task.Delay will be faulted, as is normal when a task is cancelled.

people

See more on this question at Stackoverflow