HttpMessageHandler.SendAsync(HttpRequestMessage, CancellationToken) HttpMessageHandler.SendAsync(HttpRequestMessage, CancellationToken) HttpMessageHandler.SendAsync(HttpRequestMessage, CancellationToken) Method

定义

以异步操作发送 HTTP 请求。Send an HTTP request as an asynchronous operation.

protected public:
 abstract System::Threading::Tasks::Task<System::Net::Http::HttpResponseMessage ^> ^ SendAsync(System::Net::Http::HttpRequestMessage ^ request, System::Threading::CancellationToken cancellationToken);
protected internal abstract System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken);
abstract member SendAsync : System.Net.Http.HttpRequestMessage * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>

参数

request
HttpRequestMessage HttpRequestMessage HttpRequestMessage

要发送的 HTTP 请求消息。The HTTP request message to send.

cancellationToken
CancellationToken CancellationToken CancellationToken

取消操作的取消标记。The cancellation token to cancel operation.

返回

表示异步操作的任务对象。The task object representing the asynchronous operation.

异常

requestnullThe request was null.

注解

不会阻止此操作。This operation will not block. 返回Task<TResult>读取包含内容的整个响应后,将完成对象。The returned Task<TResult> object will complete once the entire response including content is read.

SendAsync方法主要由系统。The SendAsync method is used primarily by the system. 系统调用此方法HttpClient.SendAsync调用方法。This method is called by the system one of the HttpClient.SendAsync methods is called. 大多数应用程序将永远不会调用此方法。Most apps will never call this method.

适用于