Re: Initializing the GUI from a different thread

[email protected]
Newsgroups gmane.comp.lib.fox-toolkit.user
Message-ID <[email protected]>
On 2022-02-28 09:14, Wuping Xin wrote:
> FXApp.cpp, line 1432 (and several other places),  isn't this the
> WndProc registration with the WndClass, as required by Win32 GUI
> programming?
> 
>   wndclass.lpfnWndProc=(WNDPROC) FXApp::wndproc;

Absolutely!  This is the main window proc.  But its fed by
the message queue [getNextEvent() grabs them from there].


> And WndProc in turn, calls app->dispatchEvent, which propels the
> message queue in the current thread context (i.e., the main thread).
> 
> FXival CALLBACK FXApp::wndproc(FXID hwnd,FXuint iMsg,FXuval
> wParam,FXival lParam){
>   return app->dispatchEvent(hwnd,iMsg,wParam,lParam);
>   }
> 
> But of course, each thread has its own message queue that belongs to
> its isolated thread context.   The UI thread spawned separately,
> however, does not have message dispatching needed by the UI  -  all
> messages would end up in a "black hole".

Well, that's how windows is organized.  On Linux/Unix, the event queue
does not belong to any particular thread and events are delivered to
whomever pulls them from the queue. [just not do all threads at once,
please!].

The best we can do, in portable applications, is to have a single
thread manage the GUI.  You can have as many worker threads as you
want, however.  So its a division of labor issue.


    -- JVZ
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.