Re: Initializing the GUI from a different thread
"Wuping Xin" <[email protected]>
| Newsgroups | gmane.comp.lib.fox-toolkit.user |
|---|---|
| Message-ID | <em71e3f33a-f57e-4e5b-8c2c-7aa3ccdf5bd0@wx-np8968> |
Hi Michale, After you create the App object, did you call application.init? Inside init, that is where the message loop/queue will be created for the calling thread. FxThread by default will not create the needed message queue/loop (by its design, of course). Check this out https://docs.microsoft.com/en-us/windows/win32/winmsg/using-messages-and-message-queues?redirectedfrom=MSDN "The system does not automatically create a message queue for each thread. Instead, the system creates a message queue only for threads that perform operations which require a message queue" "You create a message loop by using the GetMessage <https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getmessage> and DispatchMessage <https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-dispatchmessage> functions." <---------- FxApp makes calls to these two (or equivalents) inside FxApp.Init. I am not sure about your case, but it is definitely doable to put UI in a separate worker thread on Windows. I believe you would need some tweaks for your thread creation code. Wuping ------ Original Message ------ From: "Michael Behrisch" <[email protected]> To: "Wuping Xin" <[email protected]>; [email protected] Cc: "FOX Users" <[email protected]> Sent: 3/1/2022 10:32:06 AM Subject: Re: [Foxgui-users] Initializing the GUI from a different thread >Hi Wuping, all > >Am 01.03.22 um 14:29 schrieb Wuping Xin: >>Another question - do you use Python to spawn the threads (FxApp, FxMainWindow)? > >No, all threading is done in C++ using FXThreads. > >>>Does the FxApp instance get created/initiated/run in the SAME thread as the MainWindow instance? If they are created in different threads (different thread context), then it won't work (due to the fact that on Windows, each thread has its own message queue). > >Yes, everything in the same thread, unless there is some hidden initializiation happening when I create my FXThread. I create the app object, the window object and do app.run() in the run() method of the FXThread I create. > >Best regards, >Michael _______________________________________________ Foxgui-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/foxgui-users