Create a gist now

Instantly share code, notes, and snippets.

using Hangfire;
namespace MediatR
{
public static class MediatRExtension
{
public static void Enqueue(this IMediator mediator, IRequest request)
{
BackgroundJob.Enqueue<HangfireMediator>(m => m.SendCommand(request));
}
}
public class HangfireMediator
{
private readonly IMediator _mediator;
public HangfireMediator(IMediator mediator)
{
_mediator = mediator;
}
public void SendCommand(IRequest request)
{
_mediator.Send(request);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment