OpenReadCompletedEventArgs.Result 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取包含方法 DownloadDataAsync 下载的数据的可读流。
public:
property System::IO::Stream ^ Result { System::IO::Stream ^ get(); };
public System.IO.Stream Result { get; }
member this.Result : System.IO.Stream
Public ReadOnly Property Result As Stream
属性值
包含下载的数据的 A Stream 。
示例
下面的代码示例使用此属性返回的流。
private static void OpenReadCallback2(Object sender, OpenReadCompletedEventArgs e)
{
Stream reply = null;
StreamReader s = null;
try
{
reply = (Stream)e.Result;
s = new StreamReader(reply);
Console.WriteLine(s.ReadToEnd());
}
finally
{
if (s != null)
{
s.Close();
}
if (reply != null)
{
reply.Close();
}
}
}
Private Shared Sub OpenReadCallback2(ByVal sender As Object, ByVal e As OpenReadCompletedEventArgs)
Dim reply As Stream = Nothing
Dim s As StreamReader = Nothing
Try
reply = CType(e.Result, Stream)
s = New StreamReader(reply)
Console.WriteLine(s.ReadToEnd())
Finally
If Not s Is Nothing Then
s.Close()
End If
If Not reply Is Nothing Then
reply.Close()
End If
End Try
End Sub
注解
在使用此属性返回的数据之前,应先检查 Error 属性和 Cancelled 属性。
Error如果属性的值是对象Exception或Cancelled属性的值true,则异步操作未正确完成,Result并且属性值无效。