-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed missing CancellationToken usage in MediatR class registration #1054
Conversation
samanazadi1996
commented
Jul 28, 2024
- Added missing CancellationToken parameter to ConnectImplementationsToTypesClosing method calls.
@zachpainter77 |
The only relevant methods are the ones that already have the cancellation token passed. Your PR doesn't do anything that is valuable. The only thing that makes use of the timeout are registrations of open generic There are only two methods that call I know this because I authored the feature (#1048). I am the one who wrote the code to add the timeout configuration. It is only being used by the generics registration feature. If you are wishing to change this to work for all registrations globally then you will need to do more than pass the cancellation token to the method calls. You will need to add more places where the An open generic example: public class MyOpenGenericRequest<TEntity, TDto> : IRequest<TDto>
where TEntity : class, IEntity,
where TDto : class, IDto, new()
{
public int EntityId { get; set; }
}
public class MyOpenGenericRequestHandler<TEntity, TDto> : IRequestHandler<MyOpenGenericRequest<TEntity, TDto>, TDto>
where TEntity : class, IEntity,
where TDto : class IDto
{
private IRepository<TEntity> _repo;
private IMapper _mapper;
public MyOpenGenericRequestHandler(IRepository<TEntity> repo, IMapper mapper)
{
_repo = repo;
_mapper = mapper;
}
public async Task<TDto> Handle(MyOpenGenericRequest<TEntity, TDto> request, CancellationToken cancellationToken)
{
var entity = await _repo.FindAsync(request.EntityId);
return _mapper.Map<TDto>(entity);
}
} |
Thank you for your explanation |