[Mono-bugs] [Bug 80821][Nor] New - Wrong thread behavior with Show and ShowDialog (InvokeRequired)

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Tue Feb 13 05:49:47 EST 2007


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by bugzilla at woy.nl.

http://bugzilla.ximian.com/show_bug.cgi?id=80821

--- shadow/80821	2007-02-13 05:49:47.000000000 -0500
+++ shadow/80821.tmp.21301	2007-02-13 05:49:47.000000000 -0500
@@ -0,0 +1,74 @@
+Bug#: 80821
+Product: Mono: Class Libraries
+Version: 1.2
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Windows.Forms
+AssignedTo: toshok at ximian.com                            
+ReportedBy: bugzilla at woy.nl               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Wrong thread behavior with Show and ShowDialog (InvokeRequired)
+
+When calling ShowDialog ( or Show ) on a form on wich the InvokeRequired of
+the Owner is true, mono doesn't throw an exception. The microsoft
+implementation does.
+I Also have some problems with an unresponsive UI when using owner.Invoke (
+ShowDialog ). But I can't always reproduce that in a test application. But
+it sometimes happens with the suplied test code.
+
+The following code is from a simple test form with 3 buttons on it. The
+first button (button1_Click) just opens a Dialog. This works correct.
+
+The second button (button2_Click) tries to open a dialog in a different
+thread ( InvokeRequired prints true ). Mono opens a Dialog in this case.
+The microsoft implementation throws an exception that this is not allowed
+in a different thread.
+
+The 3rd button ( button3_Click ) tries to Invoke ShowDialog as it should be
+done. In this test application it works correct most of the time but in my
+real application this always results in an unresponsive GUI. The test
+application also sometimes have some problems displaying.
+
+public partial class TestForm : Form
+{
+    public TestForm()
+    {
+        InitializeComponent();
+    }
+
+    private void button1_Click(object sender, EventArgs e)
+    {
+        StartNewForm();
+    }
+    
+    private void button2_Click(object sender, EventArgs e)
+    {
+        ThreadPool.QueueUserWorkItem(delegate { StartNewForm(); });
+    }
+
+    private void button3_Click(object sender, EventArgs e)
+    {
+        ThreadPool.QueueUserWorkItem(delegate{ InvokeStartnewForm(); });
+    }
+
+    private void InvokeStartnewForm()
+    {
+        Invoke(new MethodInvoker(StartNewForm));
+    }
+    
+    private void StartNewForm()
+    {
+        Console.WriteLine("InvokeRequired: {0}", InvokeRequired);
+        ColorDialog dialog = new ColorDialog();
+        dialog.ShowDialog(this);
+    } 
+}
+
+P.S: this is on Mono 1.2.3 on Windows.


More information about the mono-bugs mailing list