Load Progress bar on seperate thread

ramniwas.sy

New member
Joined
Apr 29, 2010
Messages
3
Programming Experience
1-3
Frieds,

I have created a form in which i am loading thousand of records. so i want to display a progress bar.

Actually i am moving from MDI main meny to some other form so when i click that menu item i want to progress bar till my total records are not loaded.

if somebody have done this kind of problem then please help me how to do it.

Thanks
Ram Niwas
 
Do you have a loop that is loading the data?

If so, post the code and I'll put in some progress bar code for you.
 
In form load i am loading data and binding UI to xceed grid.
near about i have 20000 data to load in form.
below is code...........
------------------------------

Private Sub frmClinicalFacilityMgmt_MergeCFID_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Loding Clinical Facility data
frmCFMgmt_MergeCFID_cmbSelectTheme.SelectedIndex = 3
frmCFMgmt_MergeCFID_btnRefreshGrid.PerformClick()
End Sub
------------------------------------------
Private Sub frmCFMgmt_MergeCFID_btnRefreshGrid_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles frmCFMgmt_MergeCFID_btnRefreshGrid.Click
Try
strResult = Nothing

'lbldspMessage.Visible = True
'pgrbWait.Visible = True
'pnlProgressbar1.Visible = True
'System.Threading.Thread.Sleep(100)
'pgrbWait.Maximum = 100
'lbldspMessage.Text = "Processing."
'lbldspMessage.Refresh()
'pgrbWait.Refresh()

'Fetching Clinical Facility Data.
dsTempMergeCFID = objClsClinicalFacilityMgtMergeCFID.getClinicalFacilitiesInfo(strResult)

If strResult <> "successful" Then
MsgBox("Error Occured")
Exit Sub
End If
'Fetching Master 1572 data
objClsClinicalFacilityMgtMergeCFID.getMaster1572_CFchild(dsTempMergeCFID, strResult)
If strResult <> "successful" Then
MsgBox("Error Occured")
Exit Sub
End If
'Fetching SubInv Master 1572 data
objClsClinicalFacilityMgtMergeCFID.getSubInvMaster1572_CFchild(dsTempMergeCFID, strResult)
If strResult <> "successful" Then
MsgBox("Error Occured")
Exit Sub
End If
'Fetching Associates Certificate Details
objClsClinicalFacilityMgtMergeCFID.getAssociateCertificates_child(strResult, dsTempMergeCFID)

If strResult <> "successful" Then
MsgBox("Error Occured")
Exit Sub
End If

' Calling function to bind UI grid
bindClinicalFacilitiesToUI(dsTempMergeCFID)

Catch ex As Exception

End Try

End Sub
 
The easiest way would be to use a BackgroundWorker. Move the code you currently have for loading the data into its DoWork event handler and then call ReportProgress and handle the ProgressChanged event to update the UI along the way.

Of course, to display a real progress you have to be able to calculate a real progress, which means you must know how much you've done and how much you have to do in total. If you don't know that then the best you can do is set the Style to Marquee and display a never-ending progress.
 
Back
Top