I was looking over some old code and I found an async
method doing some async
stuff and at the end calling await Task.CompletedTask;
like below:
public async Task SomeMethod()
{
//some code
//...
await _someService.DoStuffAsync();
await Task.CompletedTask;
}
From what I read it seems safe to remove the last line, as it does not have a functional impact over the method execution, since the Task.CompletedTask
will return a task that is already completed so it will not await it, but I have second thoughts about this.
Is it safe to delete the last line? Is it redundant?