【问题标题】:Is [HttpContent.ReadAsByteArrayAsync] method guaranteed to read the full Content?[HttpContent.ReadAsByteArrayAsync] 方法是否保证读取完整内容?
【发布时间】:2014-08-06 08:46:10
【问题描述】:

没有太多关于它的文档。 http://msdn.microsoft.com/en-us/library/system.net.http.httpcontent.readasbytearrayasync(v=vs.118).aspx

如果不能保证整个Content我怎么知道什么时候停止阅读?

【问题讨论】:

    标签: c# .net http asynchronous stream


    【解决方案1】:

    你没有告诉它什么时候停止阅读。它返回一个Task<byte[]>。所以,经过一段时间后,它要么

    • 读完整个正文,然后将其作为单个byte[] 提供给您,或者
    • 遇到问题并抛出异常。

    如果没有抛出异常,则它已成功将整个正文读取为byte[]

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-15
      • 1970-01-01
      • 1970-01-01
      • 2013-08-04
      相关资源
      最近更新 更多