C
Chris Mullins
I'm seeing Control.Invoke hang on the Q/A deployment of an application. The
machine in question is a dual-proc Xeon box (with HyperThreading) running
Windows Server 2003.
The scenario that I have is a background thread creating a typed dataset,
pulling a bunch of data out of a queue to populating the dataset, then
calling control.invoke over to the main GUI thread in order to load the
dataset into a DataGrid.
I know it's hung on this line, because after installing the Remote Debugging
components, and getting the app into the broken state, I can hit pause, and
see that my thread is stuck on the _datagrid.Invoke line below.
The scenario here is that I'm in a custom trace listener, and when I get a
big enough chunk of data, I need to update the GUI - so I perform the
control.invoke, over to another method in my class, then raise an event that
any Windows Forms app can handle w/o worrying about threading issues.
'*** Member variable
Private _dataGrid As DataGrid
Sub New(ByRef dg As DataGrid)
MyBase.New(dg.Name)
_dataGrid = dg
End Sub
'*** This is called from a background thread
Public Sub WriteLine(ByVal traceMessages() As TraceMessage)
'*** Create Typed Dataset
Dim newData As New TraceItem
'*** . populate typed dataset
_dataGrid.Invoke(New NewDataForTraceDelegate(AddressOf
ThreadSafeNewDataHandler), New Object() {newData})
End Sub
Private Delegate Sub NewDataForTraceDelegate(ByVal newData As TraceItem)
Private Sub ThreadSafeNewDataHandler(ByVal newData As TraceItem)
RaiseEvent NewTraceData(newData)
End Sub
This is very puzzling to me - as it seems to happen under both low and high
load conditions. I can switch over to calling a ".BeginInvoke" on the
control, but I'm worried this won't solve the underlying problem.
machine in question is a dual-proc Xeon box (with HyperThreading) running
Windows Server 2003.
The scenario that I have is a background thread creating a typed dataset,
pulling a bunch of data out of a queue to populating the dataset, then
calling control.invoke over to the main GUI thread in order to load the
dataset into a DataGrid.
I know it's hung on this line, because after installing the Remote Debugging
components, and getting the app into the broken state, I can hit pause, and
see that my thread is stuck on the _datagrid.Invoke line below.
The scenario here is that I'm in a custom trace listener, and when I get a
big enough chunk of data, I need to update the GUI - so I perform the
control.invoke, over to another method in my class, then raise an event that
any Windows Forms app can handle w/o worrying about threading issues.
'*** Member variable
Private _dataGrid As DataGrid
Sub New(ByRef dg As DataGrid)
MyBase.New(dg.Name)
_dataGrid = dg
End Sub
'*** This is called from a background thread
Public Sub WriteLine(ByVal traceMessages() As TraceMessage)
'*** Create Typed Dataset
Dim newData As New TraceItem
'*** . populate typed dataset
_dataGrid.Invoke(New NewDataForTraceDelegate(AddressOf
ThreadSafeNewDataHandler), New Object() {newData})
End Sub
Private Delegate Sub NewDataForTraceDelegate(ByVal newData As TraceItem)
Private Sub ThreadSafeNewDataHandler(ByVal newData As TraceItem)
RaiseEvent NewTraceData(newData)
End Sub
This is very puzzling to me - as it seems to happen under both low and high
load conditions. I can switch over to calling a ".BeginInvoke" on the
control, but I'm worried this won't solve the underlying problem.