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

定义

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

public:
 virtual System::Threading::Tasks::Task<System::Net::Http::HttpResponseMessage ^> ^ SendAsync(System::Net::Http::HttpRequestMessage ^ request, System::Threading::CancellationToken cancellationToken);
public virtual 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>
override this.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 HttpClient类中的方法之一。Most applications that are connecting to a web site will use one of the SendAsync methods on the HttpClient class.

适用于