Im working on a couple of projects and one of them involves multiple windows. I dont normally have much consideration for having multiple windows open, but this one does need some sort of display.
Which got me to thinking…
We talk about the Main thread and where the GUI updates are processed and I understand that as modules and windows relate to a single instance.
But what of a window thats opened in another thread?
Im not at the computer (on my iPad now while the kids are at swimming lessons, yay!) else Id run some tests but:
- When you load or show a window, via creation of it through via New, the originating thread is still the current thread (confirming in my own mind)
- If you do create the window in another thread, for all intents and purposes, the application or originating thread is the main thread for itself, and anything run in the new window shouldnt (cant) be updating the Main window, but as far as that other (child) window is concerned, it is its own thread and would be considered the main thread for itself… yeah?
- Can you (or should you not) have each GUI on its own thread? For example, a drawing application that has a preview window (as a seperate window) I would think would be handled on the main thread, even if you are click-holding and dragging the mouse to draw a line, you would handle the update of that preview in a mouse dragging event, but if you opened another window and it was cycling through all the files in a folder and throwing thumbnails in a preview (and say there are thousands of images), you (I) would think you would/could remove that from the main drawing process of your graphic/drawing app. If you do Start a new thread (perhaps from the main app so the apparent parent window could close) then dragging either window around the desktop wont halt the other/stall
- Or is it the case that all GUI related tasks (app and / or system wide) happen on a main thread?
In essence, for the second window in its own thread, does that window consider itself the main thread? Or it is the case of #4 where there is only one main thread?
(This isnt a requirement for my current situation, more of a thought process and proof of concept)