title: How CWinThread::OnIdle is used?
body: <p>As you know, OnIdle can be specified in MFC UI thread. For details, you can read this reference <a href="http://msdn.microsoft.com/en-us/library/1sa2f19f.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/1sa2f19f.aspx</a>. But I am not sure how it can be used in practice. </p>
  
  <p>According to the reference above,</p>
  
  <p>"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."</p>
  
  <p>So I can understand that when the UI thread is not busy, the method is called.  According to the documentation above,</p>
  
  <p>"Because the application cannot process messages until OnIdle returns, do not perform lengthy tasks in this function."</p>
  
  <p>But what tasks can be done in the idle event? A single example would suffice. Thanks</p>
  
  <p>UPDATE: One discouraging fact is that <a href="http://www.microsoft.com/msj/archive/s39cd.aspx" rel="nofollow noreferrer">this old (1996) article by Russell Weisz, titled "First Aid for the Thread-Impaired: Using Multiple Threads with MFC."</a> was very helpful to understand CWinThread.</p>
  
  <p>UPDATE2: As Microsoft removed the MSJ article, <a href="http://collaboration.cmc.ec.gc.ca/science/rpn/biblio/ddj/Website/articles/CUJ/1999/9908/harring/harring.htm" rel="nofollow noreferrer">this one</a> might be helpful.</p>