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.

例外狀況

request 以前是 nullThe 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.

適用於