[Mono-dev] Threads and X-Windows?

Patrick Cullen pdcullen at gmail.com
Wed May 30 20:02:10 UTC 2012

In .NET  there is only one thread that does UI work, this is how you
access it irrespective of what thread makes the call. I use this for
event patterns often. The key is "SendOrPostCallback" which determines
if you are running on the UI thread.

I use this code often and it works under Mono. I think the behavior is
very different but the end result is what I am looking for.


protected SynchronizationContext _uiContext;
_uiContext = WindowsFormsSynchronizationContext.Current;

_uiContext.Send(new SendOrPostCallback(
	  delegate(object state)
		// * Interact with controls here
   ), null);

On Wed, May 30, 2012 at 2:56 PM, Rob Wilkens <robwilkens at gmail.com> wrote:
> I'm troubleshooting a problem in System.Windows.Forms (or an application
> which uses it):
> Does anyone know of problems where messages processed from thread a can't
> reach a window created in thread b?  That is, if thread a is processing
> messages, those messages don't reach the windows created in thread b?  By
> messages, i mean things like WM_CLOSE and WM_PAINT (or invalidate? or
> whatever the equivalents are)...  (Messages that are processed, in theory,
> by Application.Run() in thread a)...
> I'm trying to figure out if this is an X11 issue or a mono issue..  I'm
> thinking depending on how the day goes i may break from troubleshooting this
> soon.
> Before you say this is a bad idea (multiple threads creating windows) keep
> in mind this was code in a problem report and In windows .net messages
> processed in thread a reach windows created in thread b without issue.  At
> least as far as i can tell.
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list

More information about the Mono-devel-list mailing list