D
David Cartwright
Hi all,
I'm having a weird time with a call to the Refresh() method of a
DataGridView. I have a VB.NET 2005 Windows application with a main form and
a "worker" thread. The main form delegates a Sub to the worker so that the
latter can refresh the DataGrid after updating the DataTable driving it.
When I run the app under the debugger, everything's fine. But when I run it
for real, it hangs, apparently in the Refresh() method of the DataGridView -
that is, as soon as I comment out dgRefresh, the hanging goes away.
I'm dealing with the cross-thread issues appropriately, as far as I'm aware:
Public Delegate Sub dgExtRefreshCallback()
Public Sub dgExtRefresh()
dgExtensions.Refresh()
End Sub
Private Sub refreshDGExtensions()
If dgExtensions.InvokeRequired Then
Dim d As New dgExtRefreshCallback(AddressOf dgExtRefresh)
Me.Invoke(d, New Object() {})
Else
dgExtRefresh()
End If
End Sub
.... so it's "refreshDGExtensions()" that is delegated to the worker
class/thread.
I can't help thinking that there's a timing issue somewhere if it's working
in the debugger but not when run from the desktop. I figured I'd throw some
locking in to ensure that (for instance) the DataTable behind the DataGrid
didn't get updated while the DataGrid was refreshing, but that didn't seem
to help. So any ideas would be most welcome!
Thanks a lot,
David C
I'm having a weird time with a call to the Refresh() method of a
DataGridView. I have a VB.NET 2005 Windows application with a main form and
a "worker" thread. The main form delegates a Sub to the worker so that the
latter can refresh the DataGrid after updating the DataTable driving it.
When I run the app under the debugger, everything's fine. But when I run it
for real, it hangs, apparently in the Refresh() method of the DataGridView -
that is, as soon as I comment out dgRefresh, the hanging goes away.
I'm dealing with the cross-thread issues appropriately, as far as I'm aware:
Public Delegate Sub dgExtRefreshCallback()
Public Sub dgExtRefresh()
dgExtensions.Refresh()
End Sub
Private Sub refreshDGExtensions()
If dgExtensions.InvokeRequired Then
Dim d As New dgExtRefreshCallback(AddressOf dgExtRefresh)
Me.Invoke(d, New Object() {})
Else
dgExtRefresh()
End If
End Sub
.... so it's "refreshDGExtensions()" that is delegated to the worker
class/thread.
I can't help thinking that there's a timing issue somewhere if it's working
in the debugger but not when run from the desktop. I figured I'd throw some
locking in to ensure that (for instance) the DataTable behind the DataGrid
didn't get updated while the DataGrid was refreshing, but that didn't seem
to help. So any ideas would be most welcome!
Thanks a lot,
David C