UI + Threads
Posted on 2004-10-27
I just found out that I wasn't updating my GUI correctly w/ my worker threads (just doing it directly - never had a problem, but I assume race conditions could develop pretty easily). Anyways, I know I have to use Control.Invoke stuff.
My question is: does the same go for opening a new window? That is, if I want to open a new Form - think modeless dialog rather than some MDI thing - Do I have to do it from the main thread for it to persist after my thread dies?
In addition: For my own understanding, how is this actually working under the hood? When you start a new project, don't you have a GUI thread that handles UI events as well as a main worker thread? Why can you update the GUI w/ the main worker thread and now side threads? Or is there just one thread? I'm kinda confused...
When I created a Form from a worker thread, the form only lasted while the worker thread lasted - how does that fit in w/ the above? The variable w/ a handle to the form wasn't getting disposed or anything.