public async Task Invoke(HttpContext context, IUnitOfWork unitOfWork) { try { _statusReporter.AddActiveUnit(); await _next(context); await unitOfWork.SaveAsync(); } finally { unitOfWork.Dispose(); _statusReporter.RemoveActiveUnt(); } }