[Mono-dev] Threading and Winforms on Win32 only

Stifu stifu at free.fr
Tue Jun 12 05:48:36 UTC 2012


>From http://www.mono-project.com/FAQ:_Winforms:

"Mono's implementation of WinForms does not support Forms or Controls being
created on multiple threads. All Forms/Controls must be created on the same
thread.

Note this only applies to creation. You can still write multithreaded
applications that do work in other threads and modify already created
controls using Control.Invoke."


Robert Wilkens wrote
> 
> I'm getting the following exception sporadically while testing my sample 
> code that is used as a unit test (though i've never had it fail as a 
> unit test) both with and without my patch, even with mono 2.10.8 but 
> this is only happening on Windows...
> 
> System.MemberAccessException: Object is busy and cannot state allow this 
> operation [GDI+ status: ObjectBusy]
>    at System.Drawing.GDIPlus.CheckStatus (Status status) [0x00000] in 
> <filename unknown>:0
>    at System.Drawing.Graphics.FillRectangle (System.Drawing.Brush brush, 
> Int32 x, Int32 y, Int32 width, Int32 height) [0x00000] in <filename 
> unknown>:0
>    at System.Drawing.Graphics.FillRectangle (System.Drawing.Brush brush, 
> Rectangle rect) [0x00000] in <filename unknown>:0
> ...all the way back to a WM_PAINT message...
> 
> I know this is probably happening because as someone told me recently 
> somewhere (I don't know if they were right) in WinForms only one thread 
> to control the interface, the rest are background processes......and in 
> this sample code, both threads create Windows......
> 
> ...but this works in microsoft.net
> ...and it works in X11 (at least with my patch) in mono
> 
> Also, while i seem to be able to build mono in cygwin from my
> git clone git@:robwilkens/mono
> tree but , i seem to have errors when i try to compile from my
> git clone git@:mono/mono
> tree.  Am I doing something wrong or is cygwin-based windows building 
> having issues (i ask because of the question asked on the list in the 
> last 24 hours about windows builds).
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at .ximian
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 


--
View this message in context: http://mono.1490590.n4.nabble.com/Threading-and-Winforms-on-Win32-only-tp4649882p4649889.html
Sent from the Mono - Dev mailing list archive at Nabble.com.


More information about the Mono-devel-list mailing list