我是MediatR的新手。对于并发调用,MediatR会为await next()
调用抛出空引用异常。
这是我的代码。如果您需要更多信息,请与我们联系。
public class ValidatorBehaviour<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse> {
...
public ValidatorBehaviour(IValidator<TRequest>[] validators, ILogHandler logHandler) {
_validators = validators; _logger = logHandler;
}
public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TResponse> next) {
var failures = ...
if (failures.Any()) {
throw new Exception("some exception");
}
var response = await next();
return response;
}
}