public static async Task InvokeAsync(this ActionContext context, Func <CancellationToken, Task> action, ILogger logger)
        {
            //We want to handle two scenarios:
            //1) These functions are part of an ExecuteResultAsync implementation, in which case
            //they don't need to return anything. (The delegate below handles this case).
            //2) They are part of deferred processing and return a result.
            Func <CancellationToken, Task <ExecutionResult <object> > > innerAction = async(CancellationToken token) =>
            {
                await action(token);

                return(ExecutionResult <object> .Empty());
            };

            ExecutionResult <object> result = await ExecutionHelper.InvokeAsync(innerAction, logger, context.HttpContext.RequestAborted);

            if (result.ProblemDetails != null)
            {
                await context.ProblemAsync(new BadRequestObjectResult(result.ProblemDetails));
            }
        }