我无法使用HttpWebResponse.Close()关闭Silverlight中的HttpClient连接。在Wireshark中,我仍然可以看到从流中收到的所有数据包。如果我在WPF或控制台应用程序中使用完全相同的代码,则流将关闭。这是Silverlight HttpClient的错误吗?
控制台应用程序:
class Program
{
static BinaryReader BinaryReader;
static void Main(string[] args)
{
GetData();
Console.WriteLine("Press any key to close the stream...");
Console.ReadLine();
BinaryReader.Close();
Console.ReadLine();
Console.WriteLine("Press any key to close the program..");
}
static async void GetData()
{
var httpClient = new HttpClient();
var response = await httpClient.GetAsync("http://212.42.54.136:8008/mjpg/video.mjpg?camera=1", HttpCompletionOption.ResponseHeadersRead);
response.EnsureSuccessStatusCode();
BinaryReader = new BinaryReader(await response.Content.ReadAsStreamAsync());
}
}