Re: UI Thread : Where's the processing?
- From: "William DePalo [MVP VC++]" <willd.no.spam@xxxxxxxx>
- Date: Tue, 24 Jan 2006 19:40:47 -0500
"Roger Garrett" <RogerGarrett@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:70A82DD7-A979-4792-8153-6B524B575B5B@xxxxxxxxxxxxxxxx
> I guess you're right. My reading of the documentation on worker and UI
> threads left me a bit confused.
The worker / UI dichotomy is an MFC thing.
It is important to point out that at the level of the operating system, user
threads are user threads. There is no distinction between UI and worker
threads. The message queue which is necessary for a UI thread is created on
demand when a thread first performs an operation that requires a thread.
It is also important to note that windows and threads have a natural
affinity. The thread that creates a window is the one into whose message
queue the window's messages are deposited. Further, it is the only thread
that will receive the messages for the windows that it owns when it calls
GetMessage() or PeekMessage().
Now, applications which don't drain their message queue appear "stuck" or
"hung" to the user as painting goes undone and clicks and keystrokes have no
effect. For this reason, it is generally considered a good idea to perform
any long running task in a thread which does not have to pump messages.
Similarly, it is a bad idea to perform lengthy tasks in the UI thread unless
you have some way of polling the message queue periodically.
MsgWaitForMultipleObjectsEx() is good at that.
I hope that I have alleviated some confusion. If I have added to it please
post again.
Regards.
Will
.
- Follow-Ups:
- Re: UI Thread : Where's the processing?
- From: William DePalo [MVP VC++]
- Re: UI Thread : Where's the processing?
- References:
- Re: UI Thread : Where's the processing?
- From: Igor Tandetnik
- Re: UI Thread : Where's the processing?
- Prev by Date: Re: private member access
- Next by Date: Re: heap corruption
- Previous by thread: Re: UI Thread : Where's the processing?
- Next by thread: Re: UI Thread : Where's the processing?
- Index(es):
Relevant Pages
|