public async Task Invoke(IncomingLogicalContext context, IBusForHandler bus, Func<Task> next) { var messageType = context.LogicalMessage.Instance.GetType(); var handlers = registry.GetHandlers(messageType); foreach (var handler in handlers) { using (context.CreateSnapshot()) { var messageHandler = new MessageHandler { Instance = handler, Invocation = (handlerInstance, message) => registry.InvokeHandle(handlerInstance, message, bus) }; context.Handler = messageHandler; await next() .ConfigureAwait(false); if (context.HandlerInvocationAbortPending) { break; } } } }
public async Task Invoke(IncomingLogicalContext context, IBusForHandler bus, Func <Task> next) { var messageType = context.LogicalMessage.Instance.GetType(); var handlers = registry.GetHandlers(messageType); foreach (var handler in handlers) { using (context.CreateSnapshot()) { var messageHandler = new MessageHandler { Instance = handler, Invocation = (handlerInstance, message) => registry.InvokeHandle(handlerInstance, message, bus) }; context.Handler = messageHandler; await next() .ConfigureAwait(false); if (context.HandlerInvocationAbortPending) { break; } } } }
private static async Task InvokeWithDelay(IncomingLogicalContext context, Func<Task> next, int delay) { try { using (context.CreateSnapshot()) { await next().ConfigureAwait(false); } } catch (Exception) { delay += 100; await Task.Delay(delay); await InvokeWithDelay(context, next, delay); } }
private static async Task InvokeWithDelay(IncomingLogicalContext context, Func <Task> next, int delay) { try { using (context.CreateSnapshot()) { await next().ConfigureAwait(false); } } catch (Exception) { delay += 100; await Task.Delay(delay); await InvokeWithDelay(context, next, delay); } }