CWinThread::OnIdle

Override this member function to perform idle-time processing.

virtual BOOL OnIdle(
   LONG lCount 
);

Parameters

  • lCount
    A counter incremented each time OnIdle is called when the thread's message queue is empty. This count is reset to 0 each time a new message is processed. You can use the lCount parameter to determine the relative length of time the thread has been idle without processing a message.

Return Value

Nonzero to receive more idle processing time; 0 if no more idle processing time is needed.

Remarks

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.

OnIdle should return 0 to indicate that no additional idle processing time is required. The lCount parameter is incremented each time OnIdle is called when the message queue is empty and is reset to 0 each time a new message is processed. You can call your different idle routines based on this count.

The default implementation of this member function frees temporary objects and unused dynamic link libraries from memory.

This member function is used only in user-interface threads.

Because the application cannot process messages until OnIdle returns, do not perform lengthy tasks in this function.

Requirements

Header: afxwin.h

See Also

Concepts

CWinThread Class

CWinThread Members

Hierarchy Chart

CWinApp::OnIdle