典型的 Web API DelegatingHandler 实现如下所示...
protected async override Task<HttpResponseMessage> SendAsync(
HttpRequestMessage request, CancellationToken cancellationToken)
{
// TODO: Do work before inner handler here
// Call the inner handler.
var response = await base.SendAsync(request, cancellationToken);
// TODO: Do work _after_ inner handler here
return response;
}
处理CancellationToken.IsCancellationRequested == true的首选方法是什么?
我是不是该:
- 生成错误响应并中断委托链?
- 什么都不做(如上)?
- 选项“C”?