I have a method that takes a collection of objects, and in turn calls a method that handles a single object. My question is, do I need to handle the tasks coming from the DeleteSingleAsync
method since it's not really an async method or is this safe since the concrete implementation is just returning a completed task.
My initial gut concern is with exceptions/cancelation tokens not being handled correctly, or a slim possibility of a race condition in the tableTransactionActions
object.
private readonly IList<TableTransactionAction> tableTransactionActions;
public Task DeleteSingleAsync(TEntity entity, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
tableTransactionActions.Add(new TableTransactionAction(TableTransactionActionType.Delete, entity));
return Task.CompletedTask;
}
public Task DeleteAsync(IEnumerable<TEntity> entities, CancellationToken cancellationToken = default)
{
foreach (var entity in entities)
{
DeleteSingleAsync(entity, cancellationToken);
}
return Task.CompletedTask;
}
SaveChangesAsync()
). ? \$\endgroup\$