コード例 #1
0
        public async Task <TResponse> Handle(ReceiveContext <TMessage> context, MessageHandlerDelegate <ReceiveContext <TMessage>, TMessage, TResponse> nextHandler)
        {
            Guard.NotNull(nextHandler, nameof(nextHandler));
            Guard.NotNull(context, nameof(context));
            var response = await nextHandler(context);

            var tasks = this.outbox.Dequeue().Select(e => context.Publish((dynamic)e))
                        .Cast <Task>()
                        .ToList();
            await Task.WhenAll(tasks);

            return(response);
        }