Problem
Currently, Publish awaits all notification handlers.
In some scenarios (logging, telemetry, audit events),
this introduces unnecessary latency and couples request
lifetime to non-critical background work.
Current behavior
IMediator.Publish completes only after all handlers finish,
and exceptions propagate to the caller.
Proposed solution
Provide an explicit, opt-in way to dispatch notifications
in a non-blocking, fire-and-forget manner, while keeping
the current behavior as default.
Why this fits MediatR
This keeps MediatR as an in-process mediator while enabling
clear and safe background-style notifications without
manual Task.Run or ignoring returned tasks.
Alternatives
_ = Publish(...) loses error visibility
Task.Run breaks DI scopes and ASP.NET Core guidelines
- External queues add complexity for simple use cases
Example
mediator.PublishFireAndForget(new Event());
Problem
Currently,
Publishawaits all notification handlers.In some scenarios (logging, telemetry, audit events),
this introduces unnecessary latency and couples request
lifetime to non-critical background work.
Current behavior
IMediator.Publishcompletes only after all handlers finish,and exceptions propagate to the caller.
Proposed solution
Provide an explicit, opt-in way to dispatch notifications
in a non-blocking, fire-and-forget manner, while keeping
the current behavior as default.
Why this fits MediatR
This keeps MediatR as an in-process mediator while enabling
clear and safe background-style notifications without
manual
Task.Runor ignoring returned tasks.Alternatives
_ = Publish(...)loses error visibilityTask.Runbreaks DI scopes and ASP.NET Core guidelinesExample