using Elsa.Mediator.Contexts;
using Elsa.Mediator.Contracts;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Mediator.CommandStrategies;
///
/// Invokes command handlers in the background and does not wait for the result.
///
public class BackgroundStrategy : ICommandStrategy
{
///
public async Task ExecuteAsync(CommandStrategyContext context)
{
var commandsChannel = context.ServiceProvider.GetRequiredService();
await commandsChannel.Writer.WriteAsync(context.CommandContext, context.CancellationToken);
return default!;
}
}