This project has moved. For the latest updates, please go here.

Not seeing fine grained output progress

Apr 10, 2012 at 11:17 AM

I can see progress updating per file and per chunk, but not per 4096 byte stream output. I am guessing that this is because the HttpWebRequest is left with the default buffered output. This would also explain why the chunk size cannot be increased without limit without crashing Silverlight.

Am I right about this and can it be fixed by changing the C#, or is there some other explanation?

Coordinator
Apr 10, 2012 at 1:52 PM

Not sure what the exact problem is. The upload progress reports per upload chunk. You can change the upload chunk size, but this can cause errors because of webserver upload limits. 

Apr 10, 2012 at 2:36 PM

It does, which means that there is a rather long delay before you see any real progress. Most Uploaders provide continuous feedback. Your code looks like it is trying to update file progress every buffer.length (4096) bytes:

            //Read the next chunk
            while ((bytesRead = _file.FileStream.Read(buffer, 0, buffer.Length)) != 0
                && tempTotal + bytesRead <= chunkSize
                && _file.State != Enums.FileStates.Deleted 
                && _file.State != Enums.FileStates.Error
                && !_isCanceled)
            {
                requestStream.Write(buffer, 0, bytesRead);
                requestStream.Flush();

                _dataSent += bytesRead;
                tempTotal += bytesRead;

                //Notify progress change of data sent
                _uiDispatcher.BeginInvoke(delegate()
                {
                    OnUploadProgressChanged();
                });
            }

but the file progress for the whole chunk happens immediately. Perhaps this is because requestStream is buffered and so the entire chunk is written by the C# long before it is actually output...

Coordinator
Apr 10, 2012 at 2:57 PM

Yes, that's correct.

You might be able to change it by calling the OnUploadProgressChanged sooner (on the start of a chunk). Then it will report only real finished chunks.