vb.net - vb net backgroundworker + progress bar -
I want to automatically create the progress bar which will pop up when I ran my program ..
My program has 6 functions / sub which takes a considerable amount of time to complete the running query, it is input
It is about 1-2 minutes for the
backgroundworker to handle the thread and to combine it with the
progress bar
RunWorkerAsync
Personal Sub ButtonX1_Click (ByVal Handle ButtonX1.Click) as the System.Object, as byVal e System.EventArgs. Click BackgroundWorker1.WorkerReportsProgress = True BackgroundWorker1.RunWorkerAsync () End Sub Do_work
Private sub BackgroundWorker1_DoWork (ByVal as the object, byVal e System.ComponentModel.DoWorkEventArgs ) 100000000 i as integer = 0 to create_tree handles for BackgroundWorker1.DoWork () localtree () Localfrek () create_combination () showresult () if I mo d 10000000 again background 1. Report progress (i / 100) end if the next ending sub progress progress
1_ProgressChanged by Private sub background (ByVal this object As, byVal e System.ComponentModel.ProgressChangedEventArgs) Handle BackgroundWorker1.ProgressChanged ProgressBar1.Visible = True ProgressBar1.Value = e.ProgressPercentage End Sub RunWorkerCompleted
Private Sub BackgroundWorker1_RunWorkerCompleted (ByVal as the object, as byVal e System.ComponentModel.RunWorkerCompletedEventArgs) BackgroundWorker1.RunWorkerCompleted MessageBox.Show ("Work Completed!") End Sub Handle Troubleshooting -
progress bar did not pop up
for the second problem Stop because I use for loop which I use in the Do_work event
I do not know the TI passed to me So I can use random integer number for loop , do you please correct me in my program Are not you help? Thank you very much .. :)
First of all, you should set visible ProjectBar property> before calling RunWorker async .
Second, you should compare i mod 10000000
Third, if i goes up to 10000000 then i / 100 going forward 100.
Comments
Post a Comment