public async Task Invoke(HttpContext context, ITaskEngine engine) { try { await engine.RunOnBeginRequest(context.RequestAborted); await _next(context); await engine.RunOnEndRequest(context.RequestAborted); } catch (Exception e) { await engine.RunOnException(e, context.RequestAborted); throw; } }