-
March 21st, 2006, 04:49 PM
#1
strange progress bar behavior
Using MSVS 2005/.NET 2.0
I just finished porting a vb .net project from .net 1.1 to .net 2.0. All this involved was making all calls to form controls from worker threads thread-safe by using invoke. This also required me to add a sleep(1) to the end of the loops in these threads to keep control updating from being jumpy. I'm updating 5 controls, 3 of which are progress bars, 2 are labels. Pressing a button on the form fires the threads. After pressing the button for the first time after form-load, the labels update, but the progress bars do not move. If I abort the threads by clicking a cancel button, and fire the threads again, they still don't move. However, here's the weird part, if I allow the threads to finish, then fire them again, presto. The progress bars move as well as the counter labels updating. This behavior was not present before I ported it to .net 2.0. I've tried putting extra sleep statements in the threads to allow the bars to update with no effect, nothing works except for letting the threads finish then firing them again. I will post some pseudo-code showing what I'm doing.
Code:
'frm main
Private Delegate Sub stepBars(ByVal bar As ProgressBar)
Dim barStep As stepBars
...
'thread function
for x to rowcount-1
'do something
barStep = New stepBars(AddressOf progressBarStep)
cobar.BeginInvoke(barStep, cobar)
'counter label update here...but they work, so im not posting that
...
'function that is invoked, actually works with the progress bar
Private Sub progressBarStep(ByVal bar As ProgressBar)
bar.PerformStep()
End Sub
Any insight at all would be appreciated, one thought I had was perhaps JIT had something to do with it?
C G C F A D--Feel the Noise
"When your life goes nowhere and leads back to me, doesn't that tell you something?"
~Gray Area Fury
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|