Note that there are some explanatory texts on larger screens.

plurals
  1. POProgress bar value is not synchronized with what gets rendered in windows 7
    primarykey
    data
    text
    <p>It seems that in windows 7, there is some animation that takes place when setting a progress bar's value. Setting the value does not seem to wait for the animation to complete. Is there a way to be notified of when the progress bar has finished animating?</p> <p>I have a sample program. Please see the comments.</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using System.Threading; namespace Testing { static class Program { [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var form = new Form1(); form.Run(); } } public partial class Form1 : Form { public Form1() { InitializeComponent(); } public void Run() { Thread thread = new Thread ( delegate() { ProgressBarMax = 10; ProgressValue = 0; for (int i = 0; i &lt; 10; i++) { Thread.Sleep(1000); ProgressValue++; } } ); EventHandler show = delegate { thread.Start(); }; Shown += show; ShowDialog(); Shown -= show; } public int ProgressBarMax { set { Invoke ( (MethodInvoker) delegate { progressBar1.Maximum = value; } ); } } public int ProgressValue { get { return progressBar1.Value; } set { Invoke ( (MethodInvoker) delegate { label1.Text = value.ToString(); progressBar1.Value = value; // setting the value is not blocking until the // animation is completed. it seems to queue // the animation and as a result a sleep of 1 second // will cause the animation to sync up with the UI // thread. // Thread.Sleep(1000); // this works but is an ugly hack // i need to know if there is a callback to notify me // when the progress bar has finished animating. // then i can wait until that callback is handled // before continuing. // if not, do i just create my own progress bar? } ); } } } } </code></pre> <p>My google kung foo seems to be dead today. 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.
    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