I'm trying to progressively download an array of serialised data. The goal is to send a single large block from the server, and partially process it on the client whilst it downloads.
I'm using the System.Net.WebClient class and setting it's AllowReadStreamBuffering property to false. According to the MSDN documentation, this should allow me to access the incoming stream from the OpenReadCompleted event.
When I attempt to access the stream, however, it throws a NotSupportedException. This is not a cross-domain policy issue, and if I set the AllowReadStreamBuffering property to true it loads and reads the content perfectly. Am I missing something? How should I perform progressive downloads from Silverlight?
The minimal code to replicate this problem is this:
private void BeginProgressiveDownload()
{
WebClient client = new WebClient();
client.AllowReadStreamBuffering = false;
client.OpenReadCompleted += new OpenReadCompletedEventHandler(client_OpenReadCompleted);
client.OpenReadAsync(new Uri("http://STREAMABLE RESOURCE HERE"));
}
void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
e.Result.ReadByte();
}