Skip to content

Windows Form Screen frozing while calling Db.

Chinmaya Dash

Chinmaya Dash

Asked Sep 20, 2017, 7:49 AM EDT1 answer
Share
LinkedInX
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.
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)
 
 
 
Thanks in advance.

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Chinmaya Dash
    0
    Find the callback function
     
    Private Sub callbackfunction(res As IAsyncResult)
    ' 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 
    0