public static Func <Func <IReliableStateManager, ITransaction, IEvent, Task>, CancellationToken, Task> Reader(this IReliableStateManager stateManager, Func <EventData, IEvent> deserializer, string mailBoxName) => async(f, token) => { await stateManager.UseTransactionAsync(tx => stateManager.DequeueAsync( tx, e => f(stateManager, tx, e), deserializer, token, queueName: mailBoxName) ); };
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { await stateManager.DequeueAsync <IEvent>(e => { var b = e; return(Task.CompletedTask); }, deserializer, stoppingToken); await Task.Delay(1000); } }
public static Task DequeueAsync <T>(this IReliableStateManager stateManager, Func <T, Task> action, Func <EventData, T> deserializer, CancellationToken cancellationToken, string queueName = defaultOutBoxQueueName) => stateManager.UseTransactionAsync(tx => stateManager.DequeueAsync(tx, action, deserializer, cancellationToken, true, queueName), autoCommit: false);