Silverlight WebClient Progressive Download

I am trying to gradually load an array of serialized data. The goal is to send one large block from the server and partially process it on the client while it is loading.

I use the System.Net.WebClient class and set the AllowReadStreamBuffering property to false. According to the MSDN documentation, this should allow me to access the inbound stream from the OpenReadCompleted event.

However, when I try to access the stream, 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 to perform progressive downloads from Silverlight?

Minimum code to replicate this problem:

    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();
    }
+3
2

IE 4 ? IE , 4 . 4kb . :

  • , 4kb
  • , , AllowReadStreamBuffering true.
0

Source: https://habr.com/ru/post/1710242/


All Articles