Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF Progress bar not showing correct progress
    primarykey
    data
    text
    <p>I have an application where I am uploading a file in blocks. My front end is WPF and I have a progress bar to show file upload progress (upload is done by separate thread, and the progress bar is in a separate form invoked by the child thread when uploading starts).</p> <p>I found the total number of blocks in the file to set the maximum property of the progress bar.</p> <p>Now for each block uploaded I increment the value of progress bar by 1.</p> <p>But to my surprise, the progress bar starts to increment but never completes ( it stops showing progress after few blocks ).</p> <p>Here is code for the thread responsible for uploading files:</p> <pre> System.Threading.Thread thread = new Thread( new ThreadStart( delegate() { // show progress bar - Progress is the name of window containing progress bar Progress win = new Progress(); win.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; win.Show(); // find number of blocks long BlockSize = 4096; FileInfo fileInf = new FileInfo(filename); long FileSize = fileInf.Length; long NumBlocks = FileSize / BlockSize; //set the min and max for progress bar win.Dispatcher.Invoke( new Action( delegate() { win.progressBar1.Minimum = 0; win.progressBar1.Maximum = NumBlocks; } ), System.Windows.Threading.DispatcherPriority.Render); //upload file while (true) { // code to upload the file win.Dispatcher.Invoke( new Action( delegate() { win.progressBar1.Value += 1; } ), System.Windows.Threading.DispatcherPriority.Render); } } </pre> <p>Can someone help me analyze why is this happening.</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload