question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Override PublishCore

See original GitHub issue

Hello,

I am trying to override PublishCore in order to call all notification handlers and aggregate any exceptions that may occur. The problem I am running into is it seems the notification handler is executed during the enumeration.

protected override async Task PublishCore(IEnumerable<Task> allHandlers)
{
    foreach (var handler in allHandlers)  // <-- calls notification handler here
    {
        await handler.ConfigureAwait(false);
    }
}

could you please let me know how you suggest I handle this?

Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:96 (67 by maintainers)

github_iconTop GitHub Comments

2reactions
remcoroscommented, Nov 15, 2018
        public Task<IEnumerable<Vehicle>> Handle(GetVehiclesBySiteId request, CancellationToken cancellationToken)
        {
            // everything here is executed in line with whoever called this method.
           // ...
            return _repository.GetVehiclesBySiteId(request.SiteId);
        }

See the comment above, and see this: https://sharplab.io/#v2:CYLg1APgAgDABFAjAbgLAChYMQVjejKAZgQCY4BhOAbwznoRKgDY4ApAVwGcAXFgCgCUNOgzFQA7AmYA6CgHsAtgAcANgFMe64C3xiAvhiPpxTABzS4AQS4BPAHYBjAcNomxDAPSeEUlnKU1TW1dUXpDdH0gA===

By adding ‘async’ the compiler wraps the method in a state machine, doing some of it’s own exception handling.

It all comes down to the order of instructions, and who calls what.

1reaction
remcoroscommented, Nov 19, 2018

I believe you, hard to argue with what you observe 😃. Haven’t worked with Azure functions myself, so that would be interesting to see indeed. ,It’s always you, it’s never the compiler’’ is what I’ve always been told 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

MediatR 8.0 Released
... for the virtual PublishCore method that allows implementors to override the publishing strategy and accept the notification itself:
Read more >
How to add MediatR PublishStrategy to existing project
Use the MediatR DI extensions package; create a new custom class, inherit from Mediator, override the PublishCore method and add whatever ...
Read more >
dotnet publish command - .NET CLI
The dotnet publish command publishes a .NET project or solution to a directory.
Read more >
NET application publishing overview
Learn about the ways to publish a .NET application. .NET can publish platform-specific or cross-platform apps. You can publish an app as ...
Read more >
Publishing strategies in MediatR | Fati Iseni - Blog
Explore advanced publishing strategies with the MediatR library in . ... PublishCore; } protected override Task PublishCore( ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found