Hi There,
Windows Form Screen frozing while calling Db in button click to load data in Datagrid.
Taking 5 min of time to load the data in between that screen is frozing.
Taking 5 min of time to load the data in between that screen is frozing.
Some how i have implemented Asyn(Threading) process after that data is loading Data Grid Scroll bars are not working.
Please see my code bellow
Dim mk As MethodInvoker = Sub()
CheckForIllegalCrossThreadCalls = False
m_RollSortableList = New SortableBindingList(Of Global.Clopay.Gsf.Entities.QualityManagementDetailView)(RollDetailModel.GetAllFilteredMaterial(txtItemNumber.Text.Trim, txtMachineName.Text.Trim, txtJobNumber.Text.Trim, txtLotNumber.Text.Trim, reasonCodes, quality, txtLPN.Text.Trim, rolldata, txtLocation.Text.Trim))
m_RollBindingSource.DataSource = m_RollSortableList
dgvRollSets.DataSource = Nothing
dgvRollSets.Columns.Clear()
If Me.InvokeRequired Then
Me.BeginInvoke(New MethodInvoker(AddressOf RefreshDisplay))
Else
RefreshDisplay()
End If
dgvRollSets.DataSource = m_RollBindingSource
End Sub
mk.BeginInvoke(AddressOf callbackfunction, Nothing)
CheckForIllegalCrossThreadCalls = False
m_RollSortableList = New SortableBindingList(Of Global.Clopay.Gsf.Entities.QualityManagementDetailView)(RollDetailModel.GetAllFilteredMaterial(txtItemNumber.Text.Trim, txtMachineName.Text.Trim, txtJobNumber.Text.Trim, txtLotNumber.Text.Trim, reasonCodes, quality, txtLPN.Text.Trim, rolldata, txtLocation.Text.Trim))
m_RollBindingSource.DataSource = m_RollSortableList
dgvRollSets.DataSource = Nothing
dgvRollSets.Columns.Clear()
If Me.InvokeRequired Then
Me.BeginInvoke(New MethodInvoker(AddressOf RefreshDisplay))
Else
RefreshDisplay()
End If
dgvRollSets.DataSource = m_RollBindingSource
End Sub
mk.BeginInvoke(AddressOf callbackfunction, Nothing)
Thanks in advance.

Chinmaya DashPosted Sep 20, 2017, 11:50 AM
' it will be called when your job finishes.
'Thread.Sleep(5000)
MessageBox.Show("complete")
Application.DoEvents()
'
'If Me.InvokeRequired Then
' Me.BeginInvoke(New MethodInvoker(AddressOf RefreshDisplay))
'Else
' RefreshDisplay()
'End If
End Sub