0
我想調用Task.WhenAll並等待一些任務,每個任務都有自己的子任務,我想知道如果我在我的實現中正確地做到了這一點這看起來有點冗長,我想知道是否有更短的版本。任務時間多任務都有自己的任務
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);
});
}));
}