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 43700d2bcb
commit 04b74dddd0
2 changed files with 4 additions and 4 deletions

View File

@@ -137,7 +137,7 @@ internal class NotificationAsyncHandlerWrapperImpl<TNotification> : Notification
/// confusion.
/// </para>
/// </remarks>
public override Task HandleAsync(
public override async Task HandleAsync(
INotification notification,
CancellationToken cancellationToken,
ServiceFactory serviceFactory,
@@ -155,7 +155,7 @@ internal class NotificationAsyncHandlerWrapperImpl<TNotification> : Notification
(theNotification, theToken) =>
x.HandleAsync((TNotification)theNotification, theToken)));
return publish(handlers, notification, cancellationToken);
await publish(handlers, notification, cancellationToken);
}
}

View File

@@ -50,7 +50,7 @@ public partial class EventAggregator : IEventAggregator
=> _serviceFactory = serviceFactory;
/// <inheritdoc />
public Task PublishAsync<TNotification>(TNotification notification, CancellationToken cancellationToken = default)
public async Task PublishAsync<TNotification>(TNotification notification, CancellationToken cancellationToken = default)
where TNotification : INotification
{
// TODO: Introduce codegen efficient Guard classes to reduce noise.
@@ -60,7 +60,7 @@ public partial class EventAggregator : IEventAggregator
}
PublishNotification(notification);
return PublishNotificationAsync(notification, cancellationToken);
await PublishNotificationAsync(notification, cancellationToken);
}
/// <inheritdoc />