示例#1
0
文件: Mailbox.cs 项目: crapitan/Fiffi
 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)
                                            );
 };
示例#2
0
        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);
            }
        }
示例#3
0
 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);