ByteArrayContent.SerializeToStreamAsync 方法

定义

重载

SerializeToStreamAsync(Stream, TransportContext)

作为一个异步操作,将构造函数中提供的字节数组序列化并写入一个 HTTP 内容流。

SerializeToStreamAsync(Stream, TransportContext, CancellationToken)

作为一个异步操作,将构造函数中提供的字节数组序列化并写入一个 HTTP 内容流。

SerializeToStreamAsync(Stream, TransportContext)

Source:
ByteArrayContent.cs
Source:
ByteArrayContent.cs
Source:
ByteArrayContent.cs

作为一个异步操作,将构造函数中提供的字节数组序列化并写入一个 HTTP 内容流。

C#
protected override System.Threading.Tasks.Task SerializeToStreamAsync (System.IO.Stream stream, System.Net.TransportContext context);
C#
protected override System.Threading.Tasks.Task SerializeToStreamAsync (System.IO.Stream stream, System.Net.TransportContext? context);

参数

stream
Stream

目标流。

context
TransportContext

有关传输的信息,例如通道绑定令牌。 此参数可以为 null

返回

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

注解

此操作不会阻止。 当返回 Task 的对象完成时,整个字节数组已写入 stream 参数。

适用于

.NET 9 和其他版本
产品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

SerializeToStreamAsync(Stream, TransportContext, CancellationToken)

Source:
ByteArrayContent.cs
Source:
ByteArrayContent.cs
Source:
ByteArrayContent.cs

作为一个异步操作,将构造函数中提供的字节数组序列化并写入一个 HTTP 内容流。

C#
protected override System.Threading.Tasks.Task SerializeToStreamAsync (System.IO.Stream stream, System.Net.TransportContext? context, System.Threading.CancellationToken cancellationToken);

参数

stream
Stream

目标流。

context
TransportContext

有关传输的信息,例如通道绑定令牌。 此参数可以为 null

cancellationToken
CancellationToken

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

返回

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

例外

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

注解

此操作不会阻止。 当返回 Task 的对象完成时,整个字节数组已写入 stream 参数。

适用于

.NET 9 和其他版本
产品 版本
.NET 5, 6, 7, 8, 9