[Mono-bugs] [Bug 690400] New: Threading problem on Windows: mono hangs, MS implementation doesn't
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Wed Apr 27 17:36:55 EDT 2011
https://bugzilla.novell.com/show_bug.cgi?id=690400
https://bugzilla.novell.com/show_bug.cgi?id=690400#c0
Summary: Threading problem on Windows: mono hangs, MS
implementation doesn't
Classification: Mono
Product: Mono: Runtime
Version: 2.10.x
Platform: All
OS/Version: Windows
Status: NEW
Severity: Major
Priority: P5 - None
Component: JIT
AssignedTo: lupus at novell.com
ReportedBy: createsoftware at users.sourceforge.net
QAContact: mono-bugs at lists.ximian.com
Found By: Community User
Blocker: ---
Description of Problem:
(Full details about this can also be found at
http://stackoverflow.com/questions/5804076/a-threading-problem-where-mono-hangs-and-ms-net-doesnt/)
This bug in a nutshell: Mono doesn't behave on the same way on windows and
Linux in terms of threading. In certain cases, calls to Invoke never return on
windows. Everything works on Linux.
Steps to reproduce the problem:
1. Create a windows form with a label "Label1" and a button "Button1"
2. Add the following code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim T As New Threading.Thread(AddressOf Increment)
T.Start()
End Sub
Sub UpdateLabel(ByVal Text As String)
Label1.Text = Text
End Sub
Delegate Sub UpdateLabelHandler(ByVal Text As String)
Sub Increment()
Dim i As Long = 0
Dim UpdateLabelDelegate As New UpdateLabelHandler(AddressOf
UpdateLabel)
Try
While True
i = (i + 1) Mod (Long.MaxValue - 1)
Me.Invoke(UpdateLabelDelegate, New Object() {i.ToString})
End While
Catch Ex As ObjectDisposedException
End Try
End Sub
End Class
3. Run the code, and click Button1.
4. Resize the form.
Actual Results:
The thread is stopped.
Expected Results:
The thread goes on normally.
How often does this happen?
Always
Additional Information:
This only happens on windows; on Linux (fedora), mono work flawlessly. I'm
using mono 2.10 on Windows however, while the version on fedora is the one that
currently ships with fedora 14, 2.7 (I think).
Of interest is the fact that the thread hangs completely, it's not that the
display doesn't update. IIUC, the code never exits the Invoke call.
Replacing Invoke with BeginInvoke does fix the problem somehow, but the
discrepancy between mono/linux and mono/windows is still visible: while
resizing the window, the counter stops incrementing, and only restarts after.
I think that the resizing sends messages to the UI message queue and, in the
BeginInvoke case, that delays the handling of the label updating calls. In the
Invoke cases, the calls never run.
Hope this report is usefull; plenty of extra details can be found on the
aforementioned stackoverflow page.
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
More information about the mono-bugs
mailing list