Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Why are you creating a windows in a separate thread? </p> <p>I assume you are doing it because the window executes long running code or needs to be accessed by long running code, if this is true than the window will be non-responsive when the long running code is running (this is bad and can even freeze your entire system in some circumstances, but let's ignore this for a moment) - and you are doing the whole threading thing to keep the main window responsive while the second window is frozen.</p> <p>This is not supported by WPF - but even if it was supported it wouldn't have worked - Windows links the message queues of windows that are "related" to each other (it's the only way to keep the behavior of the system predictable) so the non responsive window will not process messages and that will block the queue and that in turn would prevent the owner window from receiving messages making it also non-responsive.</p> <p>There is a reason most programs have just one UI thread - the logic is simple:</p> <ul> <li><p>the only reason to run something in a different thread is if you have two or more long running or blocking operations and you don't want them to block each other.</p></li> <li><p>A window that executes long running or blocking operation will be non-responsive, that WILL affect other windows in the same app (even if they are on different threads) and might destabilize the entire system - so we don't want that.</p></li> <li><p>So me must not execute blocking or long running operations from a window but use a background thread.</p></li> <li><p>If a window does not execute long running or blocking operations it will not block the thread and therefor can run on the same thread with other well behaved windows without any problems.</p></li> <li><p>And since windows on the same thread will not interfere with each others and multi-threading adds complexity - there is no reason to ever have more then one UI thread.</p></li> </ul> <p>Note: Only one UI thread that is actually showing UI, it's perfectly fine to have background threads using WPF that will never open a window (example: create a large FixedDocument in the background) I don't call those UI threads, also I didn't say anything about the number of background threads.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload