Re: SWT/MFC UI threading question
"ultranet" <ultranet@discussions.microsoft.com> wrote in message
news:3E0A1F68-BBD0-459C-990A-F87E7FD762BE@microsoft.com...
Could you give a couple of examples of methods that have to be invoked on
the UI thread of the window?
GetMessage() and PeekMessage() are the _big_ ones. That's because each
operates on the thread's own message queue and because the messages posted
to a window are deposited into the queue of thread that owns it.
Any of these:
SetWindowText
GetWindowText
SetWindowPos
MoveWindow
?
Yes. GetWindowText() is problematic. Across threads it is far better to send
a WM_GETTEXT message than to call the function.
So you would support having all UI invocations on the UI thread, even if
it
works when being called from other threads.
:-) The world in general terms, and Windows in specific terms, is far too
complicated to permit such blanket statements to be answered with a simple
yes or no.
That said, I try to put as much of the UI logic in the UI thread as is
possible.
If you are integrating a/ a third-party component, and you not sure if
non-UI methods require to be invoked from the UI thread or not, and it
appears that they work when invoked from other threads, would you lean
towards invoking them from the UI thread anyway?
As I said, I try to put as much UI logic in a single UI thread as is
possible.
Regards,
Will