Ich möchte einen Aufruf an Task.WhenAll und warten eine Reihe von Aufgaben, die jeweils ihre eigenen Teilaufgaben haben, und ich frage mich, ob ich es in meiner Implementierung richtig mache Es scheint ein wenig wortreich und ich frage mich, ob es eine kürzere Version dafür gibt.Task WhenAll mit mehreren Aufgaben, die alle ihre eigenen Aufgaben haben
public async Task ChangeNotificationsDispatchTimeAsync(string userId, DateTime utcDateTimeToSend)
{
IList<TNotificationEntity> notifications =
await _notificationsTable.GetRowsByPartitionKeyAndRowKeyAsync(ToTicks(_now), userId, QueryComparisons.GreaterThanOrEqual);
await Task.WhenAll(
notifications.Select(notification =>
{
return new Task(() =>
{
_notificationsTable.DeleteRowAsync(notification.PartitionKey, notification.RowKey);
notification.PartitionKey = ToTicks(utcDateTimeToSend);
_notificationsTable.InsertRowAsync(notification);
});
}));
}