NetworkStream.EndRead(IAsyncResult) 方法
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
处理异步读取的结束。
public:
override int EndRead(IAsyncResult ^ asyncResult);
C#
public override int EndRead (IAsyncResult asyncResult);
override this.EndRead : IAsyncResult -> int
Public Overrides Function EndRead (asyncResult As IAsyncResult) As Integer
- asyncResult
- IAsyncResult
一个表示异步调用的 IAsyncResult。
从 NetworkStream 中读取的字节数。
asyncResult
参数为 null
。
重要
这是一个兼容性 API,不建议使用 APM (Begin/End) 方法进行新开发。 请改用基于任务的等效项。
方法 EndRead 完成由 BeginRead 方法启动的读取操作。 需要传递 IAsyncResult 由匹配 BeginRead 调用创建的 。 EndRead 将阻止调用线程,直到操作完成。
该操作读取的可用数据量最多为 参数指定的 size
字节数。
备注
如果收到 ,IOException检查 InnerException 属性,以确定它是否由 SocketException引起。 如果是这样,请使用 ErrorCode 属性获取特定的错误代码。
产品 | 版本 |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 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 | 2.0, 2.1 |