none
[U8.1]ReadOnlyStream.ReadAsync not working for Windows Phone 8.1 RRS feed

  • Question

  • I have a windows universal application catering to 8.1. I am using StreamContent.ReadAsync for reading data in chunks.

    My code is something like this

     using (Stream input = session.GetContentStream(obj, null, bytesWritten, conentStreamLength-bytesWritten).Stream)
                using (cancellationToken.Register(() => input.Dispose()))
                {
                    if (output.Length > 0)
                        output.Seek(output.Length, SeekOrigin.Begin);
    
                    int length = (int)this.document.ContentLength;
                    byte[] buffer = new byte[length];
                    int read;
    
                    while ((read = await input.ReadAsync(buffer, 0, length, cancellationToken)) > 0)
                    {
                        await output.WriteAsync(buffer, 0, read);
                        bytesWritten += read;
                        FireStatusEvent(this.document, bytesWritten, TaskCurrentStatus.InProgress, jobInProgress.Priority);
                    }
                }

    Where the input instance is of type System.Net.Http.StreamContent.ReadOnlyStream

    My tablet application is working but the windows phone 8.1

    Any hints on this ?


    Thanks and Regards,

    Saurav



    Monday, June 15, 2015 9:11 AM

All replies

  • What happens when you run this code on Windows Phone 8.1?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, June 15, 2015 4:31 PM
    Moderator
  • Thanks Matt for the reply.

    Yes this code as i mentioned does not work on Windows Phone 8.1 but works well on Tablets/PCs.

    This code is in my shared project.

    Monday, June 15, 2015 4:33 PM
  • What is the behavior? I realize it does not work, but you haven't said what exception you're receiving or the other behavior.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Tuesday, June 16, 2015 1:27 PM
    Moderator
  • Hi Matt,

    We have been using a portable class library to make http calls which was using system.net.http.

    We changed it to windows.web.http to make http calls and its working with that.

    Not sure though what was causing the problem.

    I will anyways post the stacktrace.

    Thanks and Regards,

    Saurav

    Wednesday, June 17, 2015 5:04 PM
  • Just put breaking points all over the app and see where it crashes/hangs/blows up/turns into a black hole.

    Wednesday, June 17, 2015 5:09 PM