Re: Initializing the GUI from a different thread
"Wuping Xin" <[email protected]>
| Newsgroups | gmane.comp.lib.fox-toolkit.user |
|---|---|
| Message-ID | <emde5c8276-e028-4b45-bc84-4cd82f0bbdf2@wx-np8968> |
"Just for my understanding: This means under windows it always needs to be the main thread which calls FXApp::run?" First thank you for the SUMO project. I am a user of it. - Yes. For Fox Toolkit Windows application, the main thread (which is where the entry function main() is called), and the main UI thread (which is where MainWindows and other UI elements are created), must be the same thread. This is because - dispatchEvent will be invoked in the context of the main thread, which maintains the message loop and has all the relevant internal dispatchMesage/translateMessage WIN32 call wrapped as part of FxApp's methods. If you spawn a separate thread, where you call MainWindow* mainwindow=new MainWindow(&application) - that separate thread won't have WinProc defined/registered thus there won't be any proper message loop/dispatching. Best Wuping Xin ------ Original Message ------ From: "Michael Behrisch" <[email protected]> To: [email protected] Cc: [email protected] Sent: 2/28/2022 1:42:01 AM Subject: Re: [Foxgui-users] Initializing the GUI from a different thread >Hi Jeroen and all, >thanks for the quick answer! > >Am 25.02.22 um 18:04 schrieb [email protected]: >>On 2022-02-25 09:48, Michael Behrisch wrote: >>>Dear all, >>>I have a question concerning setting up a multi threaded application. >>>We have an application (https://github.com/eclipse/sumo) which works >>>well if we initialize the FXApp and the main window from the main >>>thread but it I use another thread to initialize the GUI it does not >>>work any longer. The problem is that the application spawns more >>>threads which communicate with the main window using an event queue >>>(from the FXEX package: >>>https://github.com/eclipse/sumo/blob/main/src/utils/foxtools/FXThreadEvent.h) >>>but the main windows does not seem to get the signals any longer if we >>>start it from the secondary thread. The problem occurs only on >>>Windows, on Linux it works fine. >>> >>>We are using FOX 1.6.57 and any idea is welcome. >> >>I always *strongly* discourage letting any other thread than the >>main GUI thread perform any GUI operations. >> >>Reason is, on Windows, only the main thread can receive windows. > >Just for my understanding: This means under windows it always needs to be the main thread which calls FXApp::run? > >Best regards, >Michael > > >_______________________________________________ >Foxgui-users mailing list >[email protected] >https://lists.sourceforge.net/lists/listinfo/foxgui-users