Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's the issue:</p> <blockquote> <p>upload is done by separate thread, and the progress bar is in a separate form invoked by the child thread when uploading starts</p> </blockquote> <p>If that means your child thread <i>created</i> the form, then that's the problem. Your child thread might be updating the progress bar values, but this will just <i>invalidate</i> the display, and not necessarily refresh the display. When a control's display is <i>invalidated</i>, it simply records that it must redraw it's display the next time it gets a chance. A <i>refresh</i> is when the control actually gets to render to the screen.</p> <p>A better approach is to create the progress bar form in the <i>main</i> thread.</p> <p>Your worker thread can then update the status, and your main thread will refresh the display.</p> <p>One thing to remember: if you're updating a control that was created in a different thread, you must do so via the control's dispatcher.</p> <pre><code>var dispatcher = progressBar.Dispatcher; dispatcher.BeginInvoke(new Action( () =&gt; { progressBar.Value = currentProgress })); </code></pre> <p><hr /> <strong>Edit after seeing the code</strong></p> <p>All you need to do is move the creation of the progress variable so that it is instantiated by the main thread before the worker thread is created.</p> <hr /> <pre><code>Progress win = new Progress(); win.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; win.Show(); System.Threading.Thread thread = new Thread( new ThreadStart( delegate() { // ... </code></pre>
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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