Re: UI Thread : Where's the processing?



"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


.



Relevant Pages

  • Problem with Storable on Windows
    ... Core 4), it doesn't seem to work on Windows, returning the following ... print "Caller starting\n"; ... print "Worker started\n"; ... then reading it on the worker using sysread and using thaw ...
    (comp.lang.perl.modules)
  • Modal Dialogs on worker threads can cause exceptions in MFC with N
    ... I have an MFC application that puts up several message boxes on worker ... This has always worked when compiled with MFC 6.0. ... on Windows 2000 and Windows XP. ...
    (microsoft.public.win32.programmer.ui)
  • Re: Interacting with Windows Service (but more than just status)
    ... I will be creating a tray Icon (Notify ... Icon) and a windows form to manage this service. ... any of the worker ... What I need to do is to get some information back to the Tray Icon app or ...
    (microsoft.public.dotnet.general)
  • Re: Java Component Scheduling
    ... Each worker runs on a different host. ... If it can't it sleeps. ... Have you given any thought to using cron to handle the scheduling? ... there is a scheduler in some versions of Windows. ...
    (comp.lang.java.help)
  • Re: UI Thread : Wheres the processing?
    ... those examples all did their main processing for the thread within the InitInstance method and then returned FALSE from InitInstance to effectively shut the thread down. ... So I guess I was led astray, even farther from my initial confusion]. ... If you don't want or need a message driven thread then you can feel free to start a worker thread, ... Such a worker thread function is probably what you are looking for as the place where a thread does its "main processing." ...
    (microsoft.public.vc.language)