HttpContent.CreateContentReadStreamAsync 方法

定义

重载

CreateContentReadStreamAsync()

采用异步操作将 HTTP 内容序列化到内存流。

CreateContentReadStreamAsync(CancellationToken)

采用异步操作将 HTTP 内容序列化到内存流。

CreateContentReadStreamAsync()

Source:
HttpContent.cs
Source:
HttpContent.cs
Source:
HttpContent.cs

采用异步操作将 HTTP 内容序列化到内存流。

protected:
 virtual System::Threading::Tasks::Task<System::IO::Stream ^> ^ CreateContentReadStreamAsync();
protected virtual System.Threading.Tasks.Task<System.IO.Stream> CreateContentReadStreamAsync ();
abstract member CreateContentReadStreamAsync : unit -> System.Threading.Tasks.Task<System.IO.Stream>
override this.CreateContentReadStreamAsync : unit -> System.Threading.Tasks.Task<System.IO.Stream>
Protected Overridable Function CreateContentReadStreamAsync () As Task(Of Stream)

返回

表示异步操作的任务对象。

注解

此操作不会阻止。 在将所有内容写入内存流后,返回 Task<TResult> 的对象将完成。

操作完成后, Result 返回的任务对象上的 属性将包含表示 HTTP 内容的内存流。 然后,可以使用返回的流来使用各种流 API 读取内容。

方法 CreateContentReadStreamAsync 将内容缓冲到内存流。 如果有更好的方法将内容检索为流,则派生类可以替代此行为。 例如,字节数组或字符串可以使用更有效的方法,例如在字节或字符串周围包装只读 MemoryStream

适用于

CreateContentReadStreamAsync(CancellationToken)

Source:
HttpContent.cs
Source:
HttpContent.cs
Source:
HttpContent.cs

采用异步操作将 HTTP 内容序列化到内存流。

protected:
 virtual System::Threading::Tasks::Task<System::IO::Stream ^> ^ CreateContentReadStreamAsync(System::Threading::CancellationToken cancellationToken);
protected virtual System.Threading.Tasks.Task<System.IO.Stream> CreateContentReadStreamAsync (System.Threading.CancellationToken cancellationToken);
abstract member CreateContentReadStreamAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.IO.Stream>
override this.CreateContentReadStreamAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.IO.Stream>
Protected Overridable Function CreateContentReadStreamAsync (cancellationToken As CancellationToken) As Task(Of Stream)

参数

cancellationToken
CancellationToken

用于取消操作的取消令牌。

返回

表示异步操作的任务对象。

例外

取消令牌已取消。 此异常存储在返回的任务中。

注解

此操作不会阻止。 在将所有内容写入内存流后,返回 Task<TResult> 的对象将完成。

操作完成后, Result 返回的任务对象上的 属性将包含表示 HTTP 内容的内存流。 然后,可以使用返回的流来使用各种流 API 读取内容。

方法 CreateContentReadStreamAsync 将内容缓冲到内存流。 如果有更好的方法将内容检索为流,则派生类可以替代此行为。 例如,字节数组或字符串可以使用更有效的方法,例如在字节或 string 周围包装只读 MemoryStream )

适用于