Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Philip Hayton 98 posts 435 karma points
    Sep 07, 2022 @ 14:50
    Philip Hayton
    0

    Async notification handlers

    Hi guys,

    Does anybody know the correct way to handle calls to async methods inside a notification handler? I know there are quite a few ways to call async methods from sync code but it seems to depend on the context, and I just don't want to inadvertedly cause any locks.

    Or maybe I'm just missing something really obvious.

    Any help is greatly appreciated!

  • Obi Onuorah 2 posts 72 karma points
    Nov 12, 2023 @ 14:42
    Obi Onuorah
    0

    This question is a year old but just for anyone coming here looking for an answer, there is a version of the INotificationHandler for async operations. For example

    public class MemberNotificationHandler : INotificationAsyncHandler<MemberSavedNotification> { public async Task HandleAsync(MemberSavedNotification notification, CancellationToken cancellationToken) { ... } }

    https://apidocs.umbraco.com/v12/csharp/api/Umbraco.Cms.Core.Events.INotificationAsyncHandler-1.html

  • Iliyan 6 posts 76 karma points
    Dec 26, 2023 @ 20:41
    Iliyan
    0

    I have a handler that implements INotificationAsyncHandler. When I set a breakpoint in the HandlerAsync method, it never hits. Could it be that this Task returning method is run synchronously ?

Please Sign in or register to post replies

Write your reply to:

Draft