Groups | Blog | Home
all groups > vb.net > february 2005 >

vb.net : timers and progress bar


bbdobuddy
2/3/2005 7:57:04 PM
Hi,

I am creating a project calls a function that has to run for a while. I
would like to display a progress bar on the bottom of that form while that
function is running but everything I've tried doesn't work. It seems like it
just wants to wait for that function to finish before it does anything else.
Any help that I can get would be appreciated.

Cor Ligthert
2/4/2005 9:18:01 AM
BB,

I made this to test it and it is nicely running. Maybe can you try it
yourself.
I have set for this a statusbar on the form and on that a progressbar.

\\\
Private WithEvents tim As New Timer
Private Sub Form5_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
tim.Enabled = True
tim.Interval = 500
Me.ProgressBar1.Value = 1
Me.ProgressBar1.Step = 1
Me.ProgressBar1.Minimum = 1
Me.ProgressBar1.Maximum = 20
End Sub

Private Sub tim_Tick(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles tim.Tick
If ProgressBar1.Value <> ProgressBar1.Maximum Then
ProgressBar1.PerformStep()
Else
Me.Close()
End If
End Sub
///

Cor


Herfried K. Wagner [MVP]
2/4/2005 2:20:54 PM
"bbdobuddy" <bbdobuddy@discussions.microsoft.com> schrieb:
[quoted text, click to view]

Run the function in a separate thread to prevent blocking the UI thread.

Some information on this topic (there's a link to a C# sample for writing a
multithreaded progress form on the bottom of the page):

Multithreading in Windows Forms applications
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=multithreading&lang=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
AddThis Social Bookmark Button