Fill a progress bar after form load

ADO DOT NET

Centurion
Joined
Dec 20, 2006
Messages
160
Hi,
I have a progress bar on my start up form which I'd like to increase from its minimum to its maximum value after form loads!
Here's what I try to do on Form_Load event:
Visual Basic:
...
Me.Show()
Application.DoEvents()
For MyLoop As Integer = 1 To 100
    MainForm.EditorProgressBarItem.Value = MyLoop
    Thread.Sleep(10)
Next
But it will prevent my form controls from being activated until progress bar fully loads!

Is there any better way? I heard I should not use Thread.Sleep ?! :huh:
 
The ideal method would probably be to use a background worker for a multi-threaded approach. At the very least, throw an Application.DoEvents() in your loop. And, yes, throwing Thread.Sleep in a loop to time it is generally frowned upon.
 
Back
Top