Override PublishCore
See original GitHub issueHello,
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:
- Created 5 years ago
- Comments:96 (67 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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 😃