如何从WinRT / Metro应用程序中获取从StreamSocket.InputStream.ReadAsync读取的字节数?

时间:2012-10-12 17:57:02

标签: c# .net windows windows-runtime windows-store

我在WinRT / Metro应用程序中使用StreamSocket.InputStream.ReadAsync()进行字节读取,并且需要知道实际读取了多少字节。此读取被视为同步读取必须保持同步读取。

以下是相关的代码段:

var receivedTask = this._socket.InputStream.ReadAsync(buffer.AsBuffer(), length, Windows.Storage.Streams.InputStreamOptions.None);
receivedTask.AsTask().Start();
receivedTask.AsTask().Wait(timeout);
// Need code here to get the number of bytes received

if (receivedBytes > 0)
{
    receivedTotal += receivedBytes;
    continue;
}
else
{
    // Socket Closed
}

0 个答案:

没有答案