Control.Invoke hangs on dual-proc xeon box

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.
 
Y

Ying-Shen Yu[MSFT]

Hi Chris,





After reading your post carefully, I think we need more information to
investigate the reason of this issue. I'd like you check the following
issues, if you had already checked them, please let me know result.

First of all, I'd like to confirm if the thread had entered your event
handler ThreadSafeNewDataHandler or not (adding a debug output at the
begining of the handler could know the result).

If the event handler invoked with no problem, maybe it's handed in the
event handlers of the NewTraceData event. I'd like to know more about that
event and the event handlers.

If the event handler haven't been entered into, probably we can narrow down
this issue to the Invoke method itself.
The invoke method uses the message loop internally, I'd like you check the
the state of the main thread when the update thread hanged, was the
message loop still running at that time?


Please let me know the result these questions, to let me help investigate
this issue further.


By the way, just like to know if this issue could also be reproduced on a
single-CPU system?

Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top