How CWinThread::OnIdle is used?
As you know, OnIdle can be specified in MFC UI thread. For details, you can read this reference http://msdn.microsoft.com/en-us/library/1sa2f19f.aspx. But I am not sure how it can be used in practice.
According to the reference above,
"OnIdle is called in the default message loop when the thread's message queue is empty. Use your override to call your own background idle-handler tasks."
So I can understand that when the UI thread is not busy, the method is called. According to the documentation above,
"Because the application cannot process messages until OnIdle returns, do not perform lengthy tasks in this function."
But what tasks can be done in the idle event? A single example would suffice. Thanks
UPDATE: One discouraging fact is that this old (1996) article is very helpful to understand CWinThread.
MFC uses its default OnIdle processing to enable and disable menu items and toolbar buttons, as you can see in the documentation for CWinApp::OnIdle. There doesn't have to be explicit code to enable or disable these items as conditions change, it just happens automatically when nothing else is going on.
Windows itself uses a similar strategy for firing WM_PAINT messages - those only get generated when nothing else is in the message queue.
You use this technique when you have a low-priority task you want to do.