views:

1093

answers:

2

C# MDI application with separate GUI threads for each child in MDI is that possible ?

For example if one of the child forms is blocked by some synchronous request it freezes the entire container ( MDI Parent ) and the other windows open also become in accessible.

In general , is it possible to have more than one GUI thread in .net windows form app domain ?

In visual studio default winform application has STA ( single threaded apartment ) setup. In theory I understand what MTA means here but what is the practical use of it.

In my use case the individual mdi child are developed by various teams who may not defer blocking calls in an async manner , so I am just wondering if its possible to have multiple UI threads , although its not advisable - I completely agree.

edit #1:

I can think of google chrome browser as an example where individual tab is a separate process probably with a dedicated GUI thread ? Is something like this possible in a dot.net app.

+4  A: 

Rather than trying to force multiple threads into the GUI layer, make the GUI layer defer all its work to a background thread. That way if some background thread becomes unresponsive the whole GUI including the MDI child that is reflecting the unresponsive background thread is responsive.

fryguybob
Agree. Always better to refactor it such that your GUI runs on a single dedicated thread, and background work is assigned to worker threads which then call back onto the primary thread as work is completed.
James D
In my use case the individual mdi child are developed by various teams who may not defer blocking calls in an async manner , so I am just wondering if its possible to have multiple UI threads , although its not advisable - I completely agree.
dotnetcoder
+1  A: 

NO. You can not use multiple UI threads in .NET. You'd better use background threads to process time consuming operations there. If you need to block window while operation is running it is better to create some workaround.

In my use case the individual mdi child are developed by various teams who may not defer blocking calls in an async manner , so I am just wondering if its possible to have multiple UI threads , although its not advisable - I completely agree.
dotnetcoder
I can think of google chrome browser as an example where individual tab is a separate process probably with a dedicated GUI thread ? Is something like this possible in a dot.net app
dotnetcoder