[Mono-dev] Threads and X-Windows?
Rob Wilkens
robwilkens at gmail.com
Wed May 30 20:12:02 UTC 2012
Thanks! I thought there was supposed to be only one UI thread.
That is useful information (your sample code). I may use it as i
troubleshoot further.
I don't want to change the code i have, though, because again this code
in the report i have somehow manages to work in Windows. But i may be
able to use the information in your code sample to help make it 'work
like it works in windows/.net' at least as far as this issue I'm looking
at..
I'll do my best not to break anything in the process..
-Rob
On 05/30/2012 04:02 PM, Patrick Cullen wrote:
> 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.
>
> Patrick
>
> 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