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.

适用于