Progressbar behaves strangely
- by wanderameise
I just created an application in C# that uses a thread which polls the UART for a receive event.
If data is received an event is triggered in my main thread (GUI) and a progress bar is controlled via PerformStep() method (of course, I previously set the Max value accordingly).
PerformStep is invoked using the following expression to handle cross threading
this.Invoke((Action)delegate{progressBar2.PerformStep();})
When running this application the progressbar never hits its final value. It stops at 80%. When debugging and stopping at the line mentioned above, everything works fine using single steps. I have no idea what is going one!
Start read thread on main thread:
pThreadWrite = new Thread(new ThreadStart(ReadThread));
pThreadWrite.Start();
Read Thread:
private void ReadThread()
{
while(1)
{
if (ReceiveEvent)
{
FlashProgressBar();
}
}
}
Event that is triggered in main thread:
private void FlashProgressBar()
{
this.Invoke((Action)delegate { progressBar2.PerformStep();});
}
(It's a simplified representation of my code)
It seems as if the internal progress is faster than the visual one.