[Mono-dev] Threading and Winforms on Win32 only

Rob Wilkens robwilkens at gmail.com
Tue Jun 12 00:15:30 UTC 2012

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 
   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 at github.com:robwilkens/mono
tree but , i seem to have errors when i try to compile from my
git clone git at github.com: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).

More information about the Mono-devel-list mailing list