Added missing async awaits in notifications that ensures objects are not disposed too early

Fixes https://github.com/umbraco/Umbraco-CMS/issues/14574
This commit is contained in:
Bjarke Berg
2023-08-01 14:23:30 +02:00
parent 978da0384e
commit c11d0d3f5a
2 changed files with 4 additions and 4 deletions

View File

@@ -238,7 +238,7 @@ internal class NotificationAsyncHandlerWrapperImpl<TNotificationType> : Notifica
/// confusion.
/// </para>
/// </remarks>
public override Task HandleAsync<TNotification, TNotificationHandler>(
public override async Task HandleAsync<TNotification, TNotificationHandler>(
IEnumerable<TNotification> notifications,
CancellationToken cancellationToken,
ServiceFactory serviceFactory,
@@ -256,7 +256,7 @@ internal class NotificationAsyncHandlerWrapperImpl<TNotificationType> : Notifica
.Select(x => new Func<IEnumerable<TNotification>, CancellationToken, Task>(
(handlerNotifications, handlerCancellationToken) => x.HandleAsync(handlerNotifications.Cast<TNotificationType>(), handlerCancellationToken)));
return publish(handlers, notifications, cancellationToken);
await publish(handlers, notifications, cancellationToken);
}
}

View File

@@ -42,13 +42,13 @@ public partial class EventAggregator : IEventAggregator
}
/// <inheritdoc />
public Task PublishAsync<TNotification, TNotificationHandler>(IEnumerable<TNotification> notifications, CancellationToken cancellationToken = default)
public async Task PublishAsync<TNotification, TNotificationHandler>(IEnumerable<TNotification> notifications, CancellationToken cancellationToken = default)
where TNotification : INotification
where TNotificationHandler : INotificationHandler
{
PublishNotifications<TNotification, TNotificationHandler>(notifications);
return PublishNotificationsAsync<TNotification, TNotificationHandler>(notifications, cancellationToken);
await PublishNotificationsAsync<TNotification, TNotificationHandler>(notifications, cancellationToken);
}
/// <inheritdoc />