[Mono-bugs] [Bug 417174] New: CheckForIllegalCrossThreadCalls prevents use of Control. Invoke
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Wed Aug 13 20:07:04 EDT 2008
https://bugzilla.novell.com/show_bug.cgi?id=417174
Summary: CheckForIllegalCrossThreadCalls prevents use of
Control.Invoke
Product: Mono: Class Libraries
Version: 1.9
Platform: 32bit
OS/Version: Linux
Status: NEW
Severity: Normal
Priority: P5 - None
Component: Windows.Forms
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: andre at masella.no-ip.org
QAContact: mono-bugs at lists.ximian.com
Found By: ---
Created an attachment (id=233340)
--> (https://bugzilla.novell.com/attachment.cgi?id=233340)
C# Test Case
I have experienced this problem on Mono 1.9 and 1.9.1. On a Windows.Forms based
application, if System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls =
true, then trying to Invoke a delegate of an instantiated control will give the
exception System.InvalidOperationException: Cross-thread access of handle
detected. Handle access only valid on thread that created the control.
If the Invoke method of a control cannot be called from another thread, it
becomes difficult to communicate between worker threads and the GUI.
I have attached a test case. It gives the following output:
Starting Thread
Thread Started
Running Application
Invoking cross-thread
Unhandled Exception: System.InvalidOperationException: Cross-thread access of
handle detected. Handle access only valid on thread that created the control
at System.Windows.Forms.Control.get_Handle () [0x00000]
at (wrapper remoting-invoke-with-check)
System.Windows.Forms.Control:get_Handle ()
at System.Windows.Forms.Control.BeginInvokeInternal (System.Delegate method,
System.Object[] args, System.Windows.Forms.Control control) [0x00000]
at System.Windows.Forms.Control.Invoke (System.Delegate method,
System.Object[] args) [0x00000]
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:Invoke
(System.Delegate,object[])
at System.Windows.Forms.Control.Invoke (System.Delegate method) [0x00000]
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:Invoke
(System.Delegate)
at Test.ThreadTask () [0x00000]
It seems that the Invoke method is causing the cross-thread access by trying to
get the handle of the control.
If I set CheckForIllegalCrossThreadCalls = false, it works on Mono. It will
works either way on Microsoft .NET 2.0SP1.
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list