kevp75
asked on
WinForm Progress Bar
I have 2 forms. 1 is the main form, which grabs some files, concatenates them together, then runs a seperate method to compress them using YUI Compressor.
The second form, is simply a ProgressBar form, that I fire up using .ShowDialog in the main routine
What I am trying to do is make the progress bar show progress during the compression process (because it takes a little bit),
but I don't seem to be doing it correctly, as all that shows it the blank progress bar.
default values of the control are Minimum =0 and Maximum = 100
Here's the code for the compressor sub:
How can I make this work?
The second form, is simply a ProgressBar form, that I fire up using .ShowDialog in the main routine
What I am trying to do is make the progress bar show progress during the compression process (because it takes a little bit),
but I don't seem to be doing it correctly, as all that shows it the blank progress bar.
default values of the control are Minimum =0 and Maximum = 100
Here's the code for the compressor sub:
Private Sub CompressTheFile(ByVal _TheFilePath As String)
Dim _Progress As New Progress()
_Progress.ShowDialog()
Using _p As New Process
With _p
.StartInfo.FileName = "cmd.exe"
.StartInfo.Arguments = "/C java -jar " & My.Application.Info.DirectoryPath & "\yuicompressor-2.4.6.jar " & _TheFilePath & " -o " & _TheFilePath
.StartInfo.RedirectStandardOutput = True
.StartInfo.UseShellExecute = False
.StartInfo.CreateNoWindow = True
.Start()
For i = 0 To 10
Threading.Thread.Sleep(1)
_Progress.ProgressBar.Value += 1
_Progress.ProgressBar.Update()
Next
.WaitForExit()
End With
End Using
_Progress.Close()
End Sub
How can I make this work?
ASKER
Ok. Yes, _Progress is the Progress Bar form.
Ok, well... now it's not freezing anymore LOL, but still no progress shown
Ok, well... now it's not freezing anymore LOL, but still no progress shown
ASKER
Ok. I got it to work by changing the for loop to this:
For i = 0 To 100
Threading.Thread.Sleep(50)
_Progress.ProgressBar.Valu e = i
_Progress.ProgressBar.Upda te()
Next
however, on some longer processes, the progress bar stops before the process is completed.... so, how do I get it to keep going until the process is completed?
For i = 0 To 100
Threading.Thread.Sleep(50)
_Progress.ProgressBar.Valu
_Progress.ProgressBar.Upda
Next
however, on some longer processes, the progress bar stops before the process is completed.... so, how do I get it to keep going until the process is completed?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hehe...remove my line #9... ;)
ASKER
But I really want to fire off the calculator ;o)
Much tthanks!!!
Much tthanks!!!
You are displaying it with ShowDialog. ShowDialog freezes the procedure until the form is closed. So you procedure does not even run when the form is on the screen.
Use Show instead.